Linux basic commands

Source: Internet
Author: User
Tags clear screen gz file locale zip extension disk usage domain name registration file permissions inode usage

First, installation and landing commands
1. Enter the graphical interface
StartX
2. Enter the graphical interface
Init 5
3. Enter the character interface
Init 3
4. Login
Login
5. Shut down the machine
Poweroff
-P Turn off the power when shutting down the machine
-N does not synchronize data when shutting down the machine
-W do not shut down the operation, just to record this operation in the log
-D do not check the information recorded in the log file
-F do not call shutdown
6, Shutdown restart
Shutdown
Command format:
shutdown [Options] time [INFO]
Time-is necessary parameter, must add, can use now, also can use +5
Information--Information to the user when the computer is shut down
-t This parameter need to add a number, such as 5, indicating that the shutdown signal after 5 seconds to start shutdown-K does not do a real shutdown, just notify all users.
-R Restart the computer
-H power off after shutdown
-F skips fsck at reboot (disk checker)
-F Restart, ignore Fsck program (same as-f)
-C cancels the shutdown action that was already performed
Cases:
#shutdown-K now just kid
#shutdown-H now system shut
7. Shut down the machine
Halt
Option Same as Poweroff
8. Restart the computer
Reboot
9. Mount mount file system, umount unmount file system
Mounting discs
#mount-T Iso9660/dev/cdrom/mnt/cdrom
or #mount/mnt/cdrom.
Unmount Disc
#umount/mnt/cdrom
Exit Disc
#eject
Send to Disc
#eject-T
Mount Floppy #mount/mnt/floppy
Unmount floppy disk #umount/mnt/floppy
Mount the local FAT32 partition and display the Chinese after mounting
#mount-T Vfat-o Iocharset=cp936/dev/hda1/mnt/win
Uninstalling #/umount/mnt/win
mount a USB drive or a removable hard drive
#mount-O Iocharset=utf8/dev/sda1/mnt/usb
Uninstall #umount/mnt/usb
If the locale is not utf8, but GB18030, use the following command to Mount
#mount-O Iocharset=gb2312/dev/sda1/mnt/usb
mount a disc image to the local/mnt/cdrom directory, using the following command
#mount-T Iso9660-o loop/tmp/cd.iso/mnt/cdrom
10. command to install operating system under character interface
Linux text
11. Choose different methods to install the operating system commands
Linux Askmethod
Second, graphical interface related commands
1. System settings
Setup
2. Service startup settings
Ntsysv
3. Login Settings
Gdmsetup
Gdmconfig
4. Network Settings
Networkconfig
Thizconfig
5. Volume Control
Gnome-volume-control
6. KDE Control Center
Kcontrol
7. KDE Setup Wizard
Kpersonalizer
8. Network Detection command
Xmtr
Third, the Information display command
1. Show the time required to execute the specific instruction and the information of system resources.
Time
2. Display or set the date and time of the system
Date
#date 081112552006.35
3. Display Calendar
Cal
#cal-M
#cal-S
#cal 2006
#cal 08 2006
4, uptime
Provide user information below, no additional parameters required
The time now
The time the system is running until now
Number of users connected
System load for the last minute, five minutes, and 15 minutes
Parameter:-V Displays version information
#uptime
5. Last
Displays information about the system since it was powered on or from the beginning of the month
#last
6, DMESG
Display System-initiated information
7, Uname
Display System Information
-M display Hardware model
-N Display host name
-R Display Kernel version
-s display operating system type
-V Displays the operating system version
-A Show All information
8. Id
Display real and valid UID and GID
#id Display ID information for the current user
9, hostname
Displays or sets the host name of the system
-a displays the alias of the host
-d Display DNS domain name
-F reads the host name from the specified file
-I displays the IP address of the host
10. Who or W
Show online Login User
-Q Displays all login names and login numbers
#w display information about the current user in the system
#w User Username only displays information for the specified user
11, WhoAmI
Show the user's own identity
12. Whois
Query domain name registration and IP address related information
#whois www.sina.com.cn
Tip: If you want to register a domain name, you can use the Whois tool to check if someone is registered.
13, Whatis
View the explanation of the command
#whatis ls
14, Whereis
Displays the system command and the directory where the document is located
#whereis ls
15, which
Displays the directory where the system commands are located
#which ls
16. Stat
Displays information about the specified file (with node content)
#stat-f/View entire file system situation
17. Free
Show current memory and swap space usage
-B in bytes
-M in megabytes
18. Du
Displays the total amount of disk space used by the specified file or directory
-a displays statistics on all files (including subdirectories)
-B output result one byte bytes units
-C only calculates the total usage of the catalog
-H in M 1024kb=1m
-H in M 1000kb=1m
-S displays only the sum of the directory usage space
19, DF
Display the usage of file system disk space
-H with 1024kb=1m calculation
-H with 1000kb=1m calculation
-t specifies the type of partition to display
-I displays the inode usage of the partition
20. WC
Counts the number of bytes, words, and lines in the specified file, and displays the result output
-C Output byte count
-L Output line break statistics
-L OUTPUT the longest line length
-W Output word Count
21, LS
displaying catalog files
-A show all files (including hidden files)
-l display with long format
-F Append file categories as symbols
-R Displays the contents of the directory in a tree-like structure
-D View Directory property permissions
Ls-ld filename View file permissions
-I displays the inode number of each file
-m all items are separated by commas and fill the entire line
-H will list file size and user-friendly format output
-t lists file names in the order in which they were last modified
--color Color Display file
22. Cat
Display text file contents
-B Displays the number of rows when displaying the contents of a file
-N Display file contents including blank lines
-S merges multiple empty rows into one empty row output
Cat file names >> files 1 meaning the contents of the file are added to file 1
Cat file files 1 >> files 2 meaning to merge files and files 1 into new files 2 pieces sorting points, source files reserved
23. Tac
Reverses the display of the file contents, followed by the lines shown above
Option ditto
24. Head
Display the first lines of a text file
-N (number of rows) displays the last specified line of the file
-B (bytes) Displays the contents of the last byte of the file
-Q does not output the contents of the file header
-V Output File header contents
25, tail
Display the following lines of a text file
Option ditto
26, more or less
Pagination display of text file contents
more[file name]
Space or F page
Enter [Enter] to display the next line
Q or Q exit
-S compresses multiple empty rows into a blank line
-p Clear screen after the display
+ lines are displayed directly starting with the given number of rows
-numbers specify how many rows to display each time
27. Cut
Displays the text from the beginning of each line from NUM1 to num2

Cat Example
文件2内容的先后根据源文test2this is test1# cut -c0-6 example ## print 开头算起前 6 个字元 test2this i
28. Pwd
Show Current working directory
29. Locale
Show current locale
30, Fc-list
List system fonts
31. Jobs
View current terminal, background process under current shell
32, PS
View processes in the system
#ps aux
#ps-elf
33, Pstree
Display all trips in a tree-shaped view
34. Top
View real-time processes in the system
35. Set
viewing system Variables
36. Export
View environment variables
37, man
View command Help information
38. Info
View command Help information
39. Help
View command Help information
Iv. File processing commands
1. File
Show file types
2, mkdir
Create a Directory
-P Create a directory (build a multilevel directory)
-m specify permissions for the directory
3. grep
Finds the specified string in the specified text file
4, DD
Converting and outputting data
#dd If=/dev/hda of=/dev/hdb HDD to copy
5. Find
Find a file or directory
-name a search based on the specified file name
Example: #find. -name "*.C" (Lists all files with the current directory and its subdirectories that have the file name extension C)-type find files of the specified type
Type files are:
L Link
Catalog D
F Common Files
B-Block device files
C-Character device files
s socket (socket file)
P Piping (pipe) file
Cases:
#find ~-type D
-size N [BC] Find N-value-size files, default units are bytes
B=bit
c=kb
Cases:
#find ~-size 1500b
#find ~-size +1500b
Find files larger than 1.5M in size
#find ~-size-1500b
Find files less than 1.5M in size
-user < username > Find files belonging to a specified user
#find/-user Test
-group < user group name > Find files belonging to a specified user group
#find/-group Test
-newer < file name > Find files that are newer than files
#find/-NEWER/HOME/HTTPD
Find by Time
Tian CTime atime mtime
Minutes Cmin Amin Mmin
C-change changing the properties of a file (example: Name, type, permissions, etc.) a-access Access file is viewed
M-modify modification means that the contents of the file have been modified
-cmin +n Find files that have been modified within the last N minutes (-) or other (+)
#find ~-cmin +20
-ctime +n Find files that have been modified in the past N days (-) or other than (+)
#find ~-ctime +20
-atime +n Find files that have been read in the past n days (-) or outside (+)
#find ~-atime +20
-amin +n Find files that have been read within (-) or outside of the last n minutes (+)
#find ~-amin +20
-links N Find n number of links to a file
#find/home-links [2-5]
Connector characters
–a or or logical with or logical OR and and OR
Find ...-exec command {} \;-exec no need to ask for confirmation direct execution Command safety factor not high
{} Represents the result of the Find query
The \ Escape character indicates that the command will perform its own meaning
; End of statement
Find ...-ok command {}\;;;.
OK means asking to confirm that it is safe to ask for confirmation when executing the above command
Cases:
Find//etc–size +800000b–a–szie-204800b
Find files that are larger than 80M and less than 100M from etc
6, MV
Move a file or directory, rename a file or directory
-I appears prompt
-V Show Progress
-F Force Move
-U moves only if the source file is newer than the destination file
7. diff
Compare and display the section of file differences
8, Comm
Compare file Contents
9, Ln
Create a link between files
-s option for symbolic links
-F Force Link creation
-I appears prompt
-V Display Operation information
Ln/path/File creation hard links cannot be created across file systems equivalent to cp–p+ replication "with real-time update function ln–s/path/file name creating a soft connection can be created across file systems similar to shortcuts created under Windows 10, RM
Delete a file or directory
-R Recursive Delete
-F Force Delete
-V Displays information when deleted
-I will be prompted to confirm when deleting
11, RmDir
Delete Empty Directory
-P Delete the directory in turn
-V Displays information when deleted
12. CP
Copy a file or directory
-R recursively replicates the contents of the entire directory
-F Forced replication
-P retain the permission value of the directory after the copy has been created time
-I prompt with the same name when copying
-V Show Progress
-L Create a hard link
-U copies only when the destination file is older than the source file
13. cd
Switch directories
#cd back to the user's home directory
#cd-Go back to the user's home directory
#cd ~ Go back to the user's host directory
#cd: Go to the top level directory
#cd/Switch to the root directory
#cd. Switch to current directory
14. Tar
-F This option must be used, indicating that the file is named using the archive file
-V Show Progress
-C Build a new tar file TAR–ZCVF newfile.tar.gz newfile to NewFile packaging compression and named newfile.tar.gz
-Z Call gzip or gunzip program
-j Call bzip2 or BUNZIP2 program
-T displays the contents of the TAR package file
-X Unzip the tar file TAI–ZXVF newfile.tar.gz unzip
-R Append one or more files to the existing tar package
-U replaces files in the package if the file is newer than the package file
-K Keep the original file while unpacking the package file
-c Specifies the destination directory for unpacking
-A appends other packaged files to a packaged file
-M divides a package into multiple packages, but must be used with the-l parameter (the process of subcontracting implementation is more cumbersome)
--get extracting a file
--remove-files to delete files after packaging
-T for Test decompression, no decompression to the current directory
Format:
tar [options] generate a packaged file name for the source file to be packaged
15, Compress
Compress command, generate. z Files
16, Uncompress
Unzip a file with a. z Extension
17. zip
Compress files or directories
18, unzip
Unzip a file with a. zip extension
19. Gzip
Compression command (does not support compression of the directory), generating. gz files
1. Only compressed files cannot compress the directory
2. Do not retain the original file after compression is not the same as Windows
20, Gunzip or Zcat
Unzip the. gz file
21, Bzip2
Compress command, generate the. bz2 file
Bzip–k indicates that the original file will not be retained without K when compressing
22, BUNZIP2
Unzip command
Zip compressed file and keep the original file word zip new.zip new Zip–r new.zip represents the compressed directory
23. Touch
Change the time stamp of a file or create an empty file
24, unlink
Remove soft Links
25, locate
Search the system for files that contain strings
26, LDD
List shared libraries related to the file
V. System administration RELATED commands
1, clear ctrl+l Delete all the content before the cursor
Ctrl+u
Clear interface
2, Konsole
Open Command Terminal
3, Gnome-terminal
Open Command Terminal
4. Fdisk
modifying disk Partitions
M help
L Print a known partition
D Delete a partition
n Create a new partition
P Print the current partition table
W writes the new partition table to disk and exits
T change the system ID of a partition
Q Discard Save and exit
For example:
#fdisk/dev/hda
#fdisk-L
5, MKFS
Format Disk Utility
After typing mkfs, press the TAB key two times to show many formatting tools
6. fsck
Detect and Repair file system in single-user mode
For example:
#fsck-j/dev/hda1
Note: It is not recommended to manually fsck and the system will automatically call
7, quota
Display and limit the user's disk usage
8, Quotacheck
-A checks all non-network file systems according to/etc/mtab (with the-a parameter, you can no longer manually specify which partition to check)
-V Show procedures and results
-U check partition with Usrquota parameter
-G check partition with Grpquota parameter
-C CREATE Database Aquota.usr and Aquota.group
-M forces all partitions to be checked for read-write mode
-R checks all partitions except the root partition
#quotacheck-AVUGC
9, Quotaon
Start quota
-A open all disk quotas
-V Show Output results
-u Specifies a user-based disk quota
-g Specifies to open group-based disk quotas
-P Print Current status
10, Quotaoff
Close Quota
Option ditto
11, Edquota
Configure Limits
-U user Name
-G Group Name
-T set wide time-limited room
12, Repquota
View all quotas
13, at
Executes a specific command at a specified time
14, ATQ
Querying for tasks to be performed
15, ATRM
Delete a task to perform
16, Crontab
Set up Scheduled Tasks
17. LP
Print files
18, Useradd
New Account
19, Usermod
Modify account Settings
20, Userdel
Delete Account
21, Groupadd
Set up a group
22, Groupmod
Change the group identifier or name
23, Groupdel
Delete a group
24. Kill
To signal or terminate a program
25. Nice
Execute the program with a changed priority
26, Renice
To adjust the priority of the executing program
27, Wget
Download the file from the specified URL
28, Md5sum
Calculate and verify the software MD5 code
29, MESG
Control write access to the currently used terminal
30, Wall
Broadcast information
31. Write User name
Transmitting information to other users for real-time communication using the user must be logged on to the same host online to send a message ctrl+d end send
32.ping Ping in Lilux for infinite repetition unless CTRL + C stops
Ping–t Help information for ping commands
Ping–c number of times IP is the number of pings set
32, LPQ
List the status of the printer queue
33, LPRM
Delete a job that is printing
34. Sleep
Time suspended
35, CHFN
Change the information displayed by the finger
36, Chsh
Shell used to change user login system
VI. Network Operation related commands
1, Ifconfig
Set or display the network interface view NIC information IP address Physical Address
Ifconfig-a
2, Ifup
Enable network interface
3, Ifdown
Turn off the network interface
4. Ping
A package that transmits Icmpecho to check online status
5, Netstat
Querying the current state of a network
6. Route
Display and set up routes
7, Traceroute
Track the routers that go online
8. mtr
is a command that has both a ping function and a traceroute function.
8, xmtr
is a command that executes under X windows
9, Tcpdump
Displays the online status of TCP on the network
10. Telnet
Remote Online Program
11. FTP
File transfer
12, Rlogin
Remote Login Host
13. rcp
Remotely copying files or directories
14. SSH
Remote Encrypted online
15, Finger
Remote query for user information on host
16. Mail
Send and receive mail
17. Host
Querying the domain name used by the host
18, Nslookup
Query the network name and address of the corresponding
Vii. system security-related commands
1, passwd
Modify User Password
2, Su
Switch and replace the user's identity
Su User name High privilege user switch to low-privileged user does not need to enter a secret rights switch requires password low-privilege users to switch to each other or low-privileged users to high
3. sudo
Executes the program with the specified user rights
4, Umask
Set permissions masking for new files
That is to see the default permission value is more than the-s capitalization of the combination
(More than the mask value of the permission to know that his true permission needs to be 777 per bit minus the mask is worth the current permission value
Umask Mask value to modify the mask value of a file
5, Chgrp
Change the group to which a file or directory belongs
6, chmod
Change permissions for a file or directory
Permission objects have three U owners G belong to group O Other empowering Parameters-under Permissions + increase permissions = Direct Empowering permission also divided into three R readable W writable X executable Another special setuid=4 s for the owner plus permission if the S description is not functioning setgid=2 Group I D S is used to add permissions to the owning group =1 to other people with the permission T means directory under this permission each user can create a file but can only delete files that are the owner
Chmod O–rx Remove the permissions that other people can read and execute
Chmod g =rwx directly authorizes users to read, write, and Execute permissions
Multiple r=4 w=2 x=1 each of the three rights in real-world applications represents a class of users
Cases:
rwxr-xr-according to his authorization, each of the three rights represents a class of users corresponding to the digital permission is 754
7, Chown
Change the owner or group of a file or directory
Chown/user name/file name
8, Chattr
Change file properties
9, Lsattr
List the file attributes on ext2
10, pswho
Viii. Other Orders
1. BC
Calculator
2, Xmms
Player
3, Xine
Player
4.VI Open or create a new name file. (Touch)
Vi file name If the new is the case, if it is open, you can see the contents.
In short, whether it is a new or open existing, enter the VI interface, press I to enter the editing mode. What you said for a long time didn't respond because you didn't press I into edit mode.
Press I to enter edit mode, and then you can enter the code. Press ESC (upper left corner of the keyboard) to enter command mode when you are finished writing.
Then press shift+: Enter the last line mode. Enter WQ in the last line mode to save and Exit VI.
W filename Save and name
Wq Direct Save premise is that the file has been named: Wq=shift+zz
q! force to leave and discard the currently edited file
Set Nu (number): Set line numbers to edit large files when convenient to find changes
: Line number Direct anchor row
5. Insert command
A-------append text after the cursor
A-------Additional text at the end of our line
I-------insert text before the cursor
I-------Insert text at the beginning of the bank
o-------Insert a new line under the cursor
O-------Insert a new line on the cursor
6. Positioning commands

Linux basic commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.