首页 > IT职业 > IT职场 > Linux command line
I would be fooling myself if I claim to be proficient in Linux command line. So I took the Linux Command Line video course to enhance my knowledge in the area.
Userful Options:
| Option | Meaning |
|---|---|
| -l | use a long listing format |
| -a | do not ignore entries starting with . |
| -h | with -l, print sizes in human readable format (e.g. 1K 234M 2G) |
whatis cp // output: cp(1) - copy files
file README.md // output: README.md: ASCII text
Userful Options:
| Option | Meaning |
|---|---|
| -n | specify the number of first lines to print |
Userful Options:
| Option | Meaning |
|---|---|
| -n | specify the number of last lines to print |
| -f | loop forever, checking for new data at the end of the file(s) |
| wildcard | Meaning |
|---|---|
| * | The asterisk in a wildcard matches any character zero or more times |
| ? | A question mark matches a single character once |
| [] | match a single character in a range |
touch chapters{1,2,3}.txt
// will create chapters1.txt, chapters2.txt and chapters3.txt
Userful Options:
| Option | Meaning | Example |
|---|---|---|
| -c | create a new archive. | tar -cf archive.tar file1 file2 |
| -f | use archive file or device ARCHIVE | |
| -v | verbosely list files processed. | |
| -x | untar tar archive file | tar -cvf archive.tar |
Userful Options:
| Option | Meaning | Example |
|---|---|---|
| -O | specify output | wget -O file http://foo |
uid=501(michaelzheng) gid=20(staff) groups=20(staff),12(everyone)
groups //staff everyone
whoami //michaelzheng
For a file with listing like this:
-rw-r--r-- 1 michaelzheng staff 1983 Jul 17 16:17 README.md
The first char is the type. The 2-4 is the owner permission for reading, writing and execution respectively. 5-6 is for group members and 9-11 is for others. Taking the example above for illustration:
-: normal file
rw-: owner(i.e. michaelzheng) can read and write
r--: groups members can only read
r--: others can only read
To change each permission group, we can convert binary representation to octal format.
| r | w | e |
|---|---|---|
| 4(i.e. 2^2) | 2(i.e. 2^1) | 1(i.e. 2^0) |
Therefore, if I want to grant owner rwx(4 * 1 + 2 * 1 + 1 * 1 = 7), group member rx(4 * 1 + 2 * 0 + 1 * 1 = 5) and others r (4 * 1 + 2 * 0 + 1 * 0 = 4) then i can use
chmod 750 README.md
Useful options:
| Option | Meaning |
|---|---|
| -h | print sizes in human readable format |
du -h //output: Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1 112Gi 97Gi 15Gi 87% 2771640 4292195639 0% / devfs 182Ki 182Ki 0Bi 100% 630 0 100% /dev map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
Useful options:
| Option | Meaning |
|---|---|
| -h | print sizes in human readable format |
| -s | display only a total for each argument |
作者:不吃猫的鱼_zjh
链接:https://www.jianshu.com/p/96e7305dc685
。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1192/viewspace-2812926/ ,如需转载,请注明出处,否则将追究法律责任。