Open rogerxu opened 5 years ago
FHS (Filesystem Hierarchy Standard)
/
|- /bin
|- /boot
|- /dev
|- /etc
|- /home
|- /lib
|- /lib64
|- /media
|- /mnt
|- /opt
|- /root
|- /run
|- /sbin - System Binary
|- /srv - Service
|- /tmp
|- /usr - Unix Software Resource
|- /var - Variable
cat
由第一行開始顯示檔案內容tac
從最後一行開始顯示,可以看出 tac 是 cat 的倒著寫!nl
顯示的時候,順道輸出行號!more
一頁一頁的顯示檔案內容less
與 more 類似,但是比 more 更好的是,他可以往前翻頁!head
只看頭幾行tail
只看尾巴幾行od
以二進位的方式讀取檔案內容!umask
chattr
lsattr
file
which
- Locate a program in the user's path.
$ which -a executable
whereis
- Locate the binary, source, and manual page files for a command.
$ whereis keyword
locate
- Find filenames in the database.
$ locate pattern
find
- Find files under the given directory tree.
$ find root_path -name '*.ext'
Sector Cylinder
inode
df
- display free disk space
$ df -h
du
- display disk usage statistics
$ du -hs
ln
$ lsblk -f
$ blkid
$ parted /dev/sda print
$ tar [-z|-j|-J] [cv] [-f foo.tar.gz] filename... <== compress
$ tar [-z|-j|-J] [tv] [-f foo.tar.gz] <== view
$ tar [-z|-j|-J] [xv] [-f foo.tar.gz] [-C dir] <== decompress
type
$ type [-tpa] name
$ type ls
ls is aliased to `ls --color=auto'
$ type -t ls
alias
$ type -a ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
$ type cd
cd is a shell builtin
echo
$ echo $PATH
$ echo ${PATH}
unset
$ unset name
env
$ env
set
$ set
export
$ env name
read
$ read -p 'Please enter: ' name
Please enter: abc
$ echo $name
abc
declare
$ declare -i sum=1+2
$ echo $sum
3
Set to environment variable
$ declare -x variable
Set to local variable
$ declare +x variable
Print attributes
$ declare -p variable
declare -i variable="450"
$ arr[1]=a
$ arr[2]=b
$ echo "${arr[1]}, ${arr[2]}"
a, b
ulimit
$ ulimit -a
$ var=${str:?"Value is empty"}
str: Value is empty
alias
$ alias lm='ls -al | more'
$ history
$ history 5
Execute the last command
$ !!
stdin
: 0
,use <
or <<
stdout
: 1
,use >
or >>
stderr
: 2
,use 2>
or 2>>
$ find /home -name .bashrc > list_right 2> list_error
Only display stdout
$ find /home -name .bashrc 2> /dev/null
Redirect stderr to stdout
$ find /home -name .bashrc > list_all 2>&1
$ find /home -name .bashrc &> list_all
Copy input.txt
content to output.txt
$ cat > output.txt < input.txt
Input eof
as end of input
$ cat > output.txt << "eof"
> This is a test.
> OK now stop
> eof
[:alnum:]
- a-z, A-Z, 0-9[:alpha:]
- a-z, A-Z[:digit:]
- 0-9grep
$ grep -n --color=auto -A3 -B2 'string' filename
sed
$ nl /etc/passwd | sed '2,5d'
egrep
$ egrep -v '^$|^#' regular_express.txt
printf
awk
diff
patch
etc/passwd
etc/shadow
etc/group
useradd
passwd
usermod
userdel
id
gpasswd
setfacl
getfacl
su
sudo
visudo
/sbin/nologin
w
who
last
lastlog
鳥哥私房菜 - 鳥哥的首頁 (vbird.org)
鸟哥的Linux私房菜 基础学习篇 第四版 (豆瓣)