In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
There are many commands commonly used in Linux, such as cd, ls, pwd, du, df, tail, head, yum, mv, touch, mkdir, cp, tar and so on. The commands often used vary depending on the content of the work, such as tail, head, move, mkdir, cd, ls, cat, tar, etc. Developers often use grep, mkdir, touch, ls, pwd, cat, echo, rm, tail, wget, find, mv, and so on. Now I will briefly explain some commonly used linux.
1.cd
The cd command is often used to switch between directories, such as: cd / opt changes from the current directory to the / opt directory; when it comes to directories, we have to talk about absolute and relative paths.
Absolute path: refers to the absolute location under the directory, usually starting from the root directory, the windows root directory refers to the drive letters such as "linux /", "DRV /", etc., and the root directory of the directory refers to "/". Switch the working directory under the absolute path for example: cd / opt/abc/ relative path: refers to the relative position from the current directory, that is, where the directory is in the current directory, and the relative path represents ". /" and ".. /". Switch directories under the relative path for example: cd. / abc means to switch to the abc directory under the current directory, and cd.. / abc means to switch to the abc directory one level above the current directory.
Example:
Root@jia:~# cd / opt / / absolute path here, change directory to "/ opt" root@jia:/opt#root@jia:/opt# cd / here is absolute path, switch directory to root directory, that is, "/" root@jia:/#root@jia:/opt# cd.. / home/ here is relative path Change to the home directory root@jia:/home#root@jia:/home# cd. / jia/ in the directory one level above the current directory. / here is the relative path, change to the jia directory root@jia:/home/jia#2.ls of the current directory
The ls command is used to list the contents of the directory and folders. Syntax: ls parameter path / directory name, where the path can be absolute or relative
Introduction to common parameters of ls:
Parameter explanation-a lists all the contents under the directory, including hidden contents-A lists all the contents under the directory, including hidden contents, but does not include "." And ".. /"-b list the directory itself, that is, "."-f does not sort-I list the contents of the directory and list the index number-l to list in a long format, list permissions, owner, size, creation time, etc.-n list directories display both UID and GID and "- l" similar to-R recursive display directories, that is, display the contents of the directory under the directory at the same time And so on-S sorts by file size-t sorts by time
Example:
Root@jia:/opt# ls / / list the contents of the current directory root@jia:/opt# ls-a / / list all the contents under the current directory, including the hidden directory root@jia:/opt# ll / / equivalent to "ls-l", long format list root@jia:/opt# ls / / list the contents of the root directory root@jia:/opt# ls.. / / list the contents of the directory one level above the current directory 3.pwd
The pwd command is used to view the current working directory, that is, the path to the current directory, and the absolute path is viewed here
Example:
Root@jia:/opt# pwd/opt/root@jia:/etc/apt# pwd/etc/apt/4.touch
The touch command is used to create a file. Syntax: "touch parameter file name". It should be noted that the touch command is not a file editor.
Example:
Root@jia:/opt# touch abcroot@jia:/opt# lsjia abcroot@jia:/opt# touch test test1 test2 / / create multiple files simultaneously in the current directory root@jia:/opt# lsjia abc test test1 test2root@jia:/opt# touch / home/test / home/test1 / home/test2 / / create multiple files root@jia:/opt# ls / home/jia test test1 test25.mkdir in the home directory
The mkdir command is used to create a directory, syntax: "mkdir parameter directory name"
Introduction to common parameters:
Parameter interpretation-m creates a directory while setting permissions, similar to chmod-p recursively creating a directory-v displays the process information for creating a directory
Example:
Root@jia:/opt# mkdir testroot@jia:/opt# lsjia abc testroot@jia:/opt# mkdir-p a/b/c/d / / Recursive create root@jia:/opt# ls-R / / Recursive list jia abc test./a:b./a/b:c./a/b/c:d6.rm
Rm command is used to delete files. You can delete directories or files. Syntax: "rm parameter file name / directory name". This command is not recommended in a formal environment. Please think twice before using it. If you are not careful, it will be unforgettable for the rest of your life.
Introduction to common parameters:
Parameter explanation-f forcibly delete, delete without prompting-I confirm before deletion-r delete directory-R recursive delete-v display details of deletion process
Example:
Root@jia:/opt# lsjia abc test test1 test2root@jia:/opt# rm testroot@jia:/opt# lsjia abc test1 test2root@jia:/opt# rm-r jiaroot@jia:/opt# ls abc test1 test2root@jia:/opt# rm-rf abc / / Delete files without prompting, you can delete directories and files. Root@jia:/opt# lstest1 test27.cp is commonly used but not recommended
Cp command is used to copy files and directories. Syntax: cp parameter source file directory / target file. Only files can be copied by default, and the "- r" parameter is required to copy the directory.
Introduction to common parameters:
Parameter explanation-f do not ask before overwriting-I ask before overwriting-l do not copy linked files-n do not overwrite existing files-r copy directory-R recursively copy files and directories under the directory
Example:
Root@jia:/opt# cp test1 / etc/ copy test1 from the current directory to root@jia:/opt# ls / etc/.... under the / etc directory Ignore abc directory under other test1root@jia:/opt# cp-r abc / etc/ copy directory to 8.mv under / etc directory
Mv command is used to move files and directories. Syntax: mv parameter source file target directory. Here is a mv technique. Mv can not only move files but also rename files. When the source and target directories are the same, the files will be renamed.
Introduction to common parameters:
Parameter interpretation-f do not ask before coverage-I ask before coverage-n do not overwrite when moving
Example:
Root@jia:/opt# mv test1 / / move the file test1 to the root directory root@jia:/opt# lstest2root@jia:/opt# mv test2 test1 / / rename test2 to test1root@jia:/opt# lstest19.cat
The cat command is used to display all the contents of the file, syntax: cat parameter file
Introduction to common parameters:
Parameter interpretation-b to number non-blank output lines-E to add a $sign at the end of the line-n to number all line outputs-s multiple blank lines will be displayed as a blank line
Example:
Root@jia:/opt# cat test2 file contents root@jia:/opt# cat > > test2 file name input line 2 > input line 3EOF10.head
The head command is used to display the contents of the file and to view the first few lines of the file. Syntax: head parameter file
Example:
Root@jia:/opt# head-100 test1 / / display the first 100 lines of the file root@jia:/opt# head-10 test1 / / display the first 10 lines of the file the first 10 lines of the file 11.tail
The tail command is used to dynamically display the contents of the file, to view the last few lines of the file, and to reverse the first few lines and the last few lines with head. Syntax: tail parameter file
Introduction to common parameters:
Parameter interpretation-f displays the contents of the file in real time, that is, dynamically view the contents of the file-n how many lines of the output file
Example:
Root@jia:/opt# tail-100 test1 / / displays the last 100 lines in the test1 file, root@jia:/opt# tail-f test1 / / dynamically displays the contents of the file, which is mostly used for log queries and log scheduling tests. It is strongly recommended that operators remember 12.df.
The df command is used to view disk partitions. Syntax: df parameter, common parameter combination: df-lh
Introduction to common parameters:
Parameter introduction-a shows the usage of all file systems-h is displayed in readable size units-H is displayed in readable size units, but not in 1024. Calculate in 1000-I display the index information of the file system-k display the file system in K-t display information for the specified file system type-T displays only the file system type-l displays the file system information in a long format
Example:
Root@jia:/opt# df-lh / / View file system details Filesystem Size Used Avail Use% Mounted onudev 921M 0921m 0 / devtmpfs 193M 944K 192 M 1% / run/dev/sda2 98G 3.7G 90G 4% / tmpfs 962M 0962m 0% / dev/shmtmpfs 5.0M 05.0M 0% / run/locktmpfs 962M 0962M 0% / sys/fs/cgroup/dev/loop0 90M 90M 0% / snap/core/7917/dev/loop1 55M 55M 0% / snap/lxd/12211tmpfs 193M 0 193M 0% / run/user/013.du
Du command is often used to check disk usage, file directory and file size, syntax: du parameter, common command: du-sh
Introduction to common parameters:
Parameter interpretation-an outputs all file disk sizes, including directory-c display total size-h displays file size in a readable manner-k displays file size in K-m displays file size in M-S does not display the size of subdirectories-s displays the sum of query file sizes root@jia:/opt# du-sh / / displays the total size of query files 5.2m .14.echo
The echo command is used to print characters, syntax: echo characters
Example:
Root@jia:/opt# echo 123123root@jia:/opt# echo abc > test1 / / output characters to test1 file, overwrite file root@jia:/opt# echo 123 test1 / / output characters to test1 file, add to file 15.find
Find command for file lookup or directory lookup, syntax: find path parameter parameter value
Introduction to common parameters:
Parameter interpretation-name queries files by name-user users query files-group queries files according to group query files-mtime photos change time-ctime photos create time to query files-type queries files by file type-size queries by file size-prune ignores a directory-depth looks up the current directory and then queries the subdirectory
Example:
Root@jia:/opt# find. /-name "* .txt" | xargs rm / / Delete all files ending in txt in the current directory root@jia:/opt# find / home-size + 512k / / look up files greater than 512k root@jia:/opt# find / home-size-512k / / look up files less than 512k root@jia:/opt# find / home -links + 2 / / look for files or directories with more than 2 hard connections root@jia:/opt# find / home-perm 0700 / / look for files or directories with permissions of 700. root@jia:/opt# find /-amin-10 / / find files accessed in the last 10 minutes in the system root@jia:/opt# find /-atime -2 / / find files accessed in the last 48 hours in the system root@jia:/opt# find /-empty / / find files or folders that are empty in the system root@jia:/opt# find /-groupcat / / find files belonging to groupcat in the system root@jia:/opt# find /-mmin-5 / / find files modified in the last 5 minutes in the system root@jia:/opt# find /-mtime-1 / / find files modified in the last 24 hours in the system root@jia:/opt# find /-nouser / / find files that belong to invalid users in the system root@jia:/opt# find /-user fred / / check Find the file 16.wget that belongs to the user FRED in the system
Wget is a tool for downloading files, which is used on the command line. Syntax: wget parameter connection address
Introduction to common parameters:
Parameter explanation-b background downloads-Q silent downloads-v downloads details-nc downloaded files do not repeat downloads-c continue downloading to download partial files-S print server response-4 connect only ipv4 connections-6 connect only ipv6 connections-nd do not create directories-x force create directories-nH do not create home directories-http-user=user sets http user name -- http-password=pass sets http user password-- secure-protocol=auto selects security protocol to download Parameters include auto, SSLv2, SSLv3, TLS v1--ftp-user=user set ftp user name-ftp-password=pass set ftp password-r recursively download
Example:
Root@jia:/opt# wget http://nginx.org/download/nginx-1.17.6.tar.gz / / download nginx to the current directory with the file name nginx-1.17.6.tar.gz
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.