A, file and directory operation command
1, ls command
Function: Display information of files and directories.
Ls displays the current directory file list by default.
Ls -a displays all files, including hidden files.
Ls -l displays file properties, including size, date, symbolic link, whether it can be read or written, and whether it can be executed.
Ls -lh displays the file size and prints the file size in an easy-to-understand format (for example, 1K 234M2G).
Ls -lt displays files, sorted by modification time.
2.cd command
Function: Rename Directory
Cd dir switches to the dir directory in the current directory.
CD/ switch to the root directory
Cadmium .. Switch to the previous directory.
Cadmium .../... Switch to the superior secondary directory.
Cd ~ Switch to the user directory, such as root, and then switch to /root.
The difference between root directory and home directory:
The root directory is the first-level file structure of the system, and the home directory is only the directory controlled by non-root users. Equivalent to windows My Documents, non-root users can only control files in the home directory, but not other files in the root directory.
The root directory is the top-level directory of the device, which is marked with/
The home directory is the directory where each user logs into the system. Usually under /home, the user name is the directory, which can be represented by ~.
CD/ input root directory
Cd ~/ enter the home directory
Of course, you can also use /home/someone to enter someone's home directory.
3.cp command
Function: Copy files
Cp source target copies the file source as the target.
Cp /root /source。 Copy the file source under /root to the current directory.
For example: cp/home/open _ 038 _ dev/external _ files/test/test.sh.
CP–avsour _ dir target _ dir copies the entire directory, and the two directories are exactly the same.
4.rm command
Function: Delete files or directories.
Rm file deletes a file.
Rm -f file was deleted without prompting. Can be used with the r parameter.
Rm -rf dir deletes the entire directory named dir in the current directory.
5.mv command
Function: Move the file or rename it. There is no rename command under uinx. If you want to rename it, you can use this command.
Mv source target renames the file source to the target.
Command parameters:
-b: If you need to overwrite the file, please back it up before overwriting it.
-f: Forcing means directly overwriting the target file without asking if it already exists;
-i: If the target file already exists, you will be asked whether to overwrite it!
-u: If the target file already exists and the source file is relatively new, it will be updated.
-t:-target-directory = directory moves all source parameters to the directory, which is the target directory of the specified mv. This option is suitable for moving multiple source files to a directory, with the target directory first and the source files last.
Example 1: Rename file
Command:
Mv test. log test 1.txt
Example 2: Moving files
Command:
mv test 1.txt test3
Move the files log 1.txt, log2.txt and log3.txt to the directory test3.
mv log 1 . txt log 2 . txt log 3 . txt test3
Change the file log1.txtlog2.txtlog3.txt to the directory /opt/soft/test/test4.
mv-t/opt/soft/test/test 4/log 1 . txt log 2 . txt log 3 . txt
Move all files in the current folder to the previous directory.
mv *../
6. Differences
Function: Compare file contents
Diff dir 1 dir2 compares whether the file lists in directory 1 and directory 2 are the same, but does not compare the actual contents of the files, and lists them if they are different.
Diff file 1 file2 compares whether the contents of file 1 and file 2 are the same. If it is a file in text format, different contents will be displayed. If it is binary code, it can only show that the two files are different.
Comm file 1 file2 compares files and displays the different contents of the two files.
7.ln command
Function: Create a link. Windows shortcuts are based on the link principle.
Source path target path hard connection
Ln -s source path target path soft connection
Ln is another very important command in linux. Its function is to establish different links for files in another location. The most commonly used parameter of this command is -s, and the specific usage is: ln–s source file target file.
When we need to use the same file in different directories, we don't need to put the same file in every needed directory. We just need to put the files in a fixed directory, and then link them in other directories with ln command, without occupying disk space repeatedly. For example: ln–s/bin/less/usr/local/bin/less.
blogs . com/joeblackzqq/archive/20 1 1/03/20/ 1989625 . html
Second, view the file content command.
1, cat command
Displays the contents of the file, which is the same as DOS type.
Caterpillar documents
2. More commands
Function: Paging display command
More documents
The more command can also be used with other commands through the pipe character (|), for example:
Ps ux | more
Ls | more
3. Tail command
Function: display the last few lines of the file.
Tail -n 100 aaa.txt displays the last 100 line of the file aaa.txt
4.vi command
Vi file editing file
Vi Original Basic Usage and Commands:
The way to enter a command is to press the [ESC] key first, and then enter: w (writing to a file),: w! (Write a file without asking),: wq Save and exit,: q Exit, q! Exit without saving.
5. Touch command
Function: Create an empty file.
Touch aaa.txt to create an empty file named aaa.txt.
Third, the basic system command
1, manual command
Function: View the help of the command. If you don't know the usage of a command, you can ask him and he will tell you when he knows.
For example:
Man ls displays the help content of ls command.
2, w command
Function: Display the details of the logged-in user.
For example:
Sergeant: ~# w
22:06:5 1 rising for 43 minutes, 1 user, average load: 0.00, 0.00, 0.00.
User TTY who logs in to @ IDLE JCPU PCPU WHAT.
Zhou ljpts/010.140.0.10921:24 0.00s0.85s0.09ssshd: Zhou lj [priv]
3. Who ordered it
Function: display logged-in users
For example:
Sergeant: ~ # Who
Zhou ljpts/0mar1321:24 (10.140.0.109)
4. The last command
Function: Check which users have recently logged into the system.
For example:
Sergeant: ~ # Last one
Still logged in.
Restart the system and start 2.6.8-2-386 Monday to March 13 2 1:23 (00:43)
Sunday pts/010.140.0.105 Mar 12 22:5 1-down (00:00)
Sunday pts/010.140.0.105 Sun Yue12 22: 51-22: 51(00: 00)
root tty 1 Sun Mar 12 22:50-down(00:0 1)
root tty 1 Sun Mar 12 22:46-22:48(00:02)
root tty 1 Sun Mar 12 22:43-22:46(00:02)
Restart the system and start 2.6.8-2-386 Monday to March 13 06:34 (-7:-4 1)
Wtmp started in March 20061306: 34:11
5. Date command
Function: system date setting
Date displays the current date and time.
Date -s 20:30:30 Set the system time to 20:30:30.
Date-March 5, 2002 sets the system cycle to March 5, 2003.
Date -s "060520 06:00:00 "sets the system cycle to 6:00 sharp on May 20, 20 06.
6. Clock command
Function: clock setting
Clock–r reads the time parameter in the system Bios.
Clock–w writes the system time (such as the time set by date) into the Bios.
7.uname command
Function: View system version
Uname -R displays the version of the operating system kernel.
For example:
Sergeant: ~# uname -a
Linux Sarge 2.6.8-2-386 # 1 Tuesday aug1612: 46: 35 utc2005i686gnu/Linux.
8, shut down and restart the system command
Restart the computer.
Shutdown -r Restart the computer now, and restart the computer after stopping the service.
Shutdown -h Now shut down the computer, stop the service, and then shut down the system.
Halt turns off the computer.
Shutdown -r is usually used now. When the system was restarted, the related services were shut down, and so is shutdown -h now.
9, Sue command
Function: Switch users
Su- switch to the root user
Su-zhoulj switches to zhoulj users,
Note:-It's critical. If-is used, the user's environment variable will be used.
Name server192.168.1.11
6. Network debugging
(1), ping command
Function: Forget it. Do it if you don't know.
thump
(2), traceroute command
Function: route tracking
traceroute
Trace route 207.68. 173.7
(3), nslookup command
Function: domain name resolution and debugging
For example:
$ nslookup
Note: nslookup has been deprecated and may be removed from future versions.
Consider using "dig" or "host" programs. Run nslookup using.
` -sil[ent]' option to prevent this message from appearing.
& gt
Server:192.168.1.11
Address:192.168.1.11# 53
Non-authoritative answer:
Name:
Address: 202. 1 18.66.66
> server 202. 1 18.66.6
Default server: 202. 1 18.66.6.
Address: 202. 1 18.66.6#53
& gt
Server: 202. 1 18.66.6
Address: 202. 1 18.66.6#53
Non-authoritative answer: canonical name =
.
Name:
Address: 202. 108.22.5
IX. Other orders
1 and ssh commands
Function: Remote login to other UNIX hosts.
Ssh-l user 1192.168.1.2 Log in to 192. 1.2 with user name.
hush
Log in with the user name user 1192.168.1.2.
2, scp command
Function: secure copy
For example:
scp abc.tar.gz
: ~ Copy the local abc.tar.gz to the root directory of user1(/home/user1) in192.10.5.
3.telnet command
Function: Log in to the remote host.
For example:
Remote login192.168.1.5
————————————————
Copyright statement: This article is a CSDN blogger "Sunshine ~ L &;; H "follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement.
Original link: /LH 09 12666/ Article/Details /87897629