文件操作类

简写 解析
ls list files
ls -a list files all
ls -l list files list
ls -al list files all list
pwd print work directory
cd <dirname> change directory
cd - change to last directory
cd ~ change to root drrectory
mkdir <dir> make a empty directory
mkdir -p <dir>/<dir> make parents a/b/c
mkdir -p <dir>/{<dir>,<dir>} make parents a/{b,c}/d
rmdir <dir> remove empty directory
tree show floder tree
touch <file> create file or refresh file
cat -n <file> concatenate | view file and show number
cat > <file> create file and echo file
cat <file> <file> > <file> merge file
mv <dir> <dir> move directory or rename
cp <file> <file> copy file
cp -a <dir> <dir> copy directory
cp dir/* . copy directory to here
rm -rf <dir/file> remove file
ln -s <dir/file> link create link
ln <dir/file> link create link but link can change file
find <dir> -name string find file by name
grep Globally search a Regular Expression and Print
grep <string>' dirPath/* find a str in a directory
less -N <file> view file and show number q,d,b,PGUP,PGDN
tail <file> view last ten lines
head <file> view the header of the file for 10
tar Tape Archive
-c -v -f -z -t -x create/view/filename/GNUzip/list/extract
tar –cvf <string>.tar <file/dir> packed file
tar -zcxf <string>.tar.gz <file/dir> packed file and GUNzip
tar -xvf <string>.tar/gz <file/dir> extract file
wc -l view wordCount line
cut -f <number> -d <string> cut filed number Separator string

系统常用命令

简写 解析
uname -a show unix name all info
cat /etc/issue view ubuntu issue version
ps -a show all process status
ps |grep <string> find process name or portid
kill -9 [PID] kill process by PID
cal 2019 view 2019 calendar
apt -get install APP advanced package tool intsall application
apt-get remove APP uninstall software
apt-get update update software source
apt-get upgrade upgrade software

系统目录

简写 解析
/bin user binaries 存储常用文件操作命令
/sbin system binaries 存储系统配置命令
/etc configuration Files 应用配置文件
/dev devices files 外接设备
/proc process information 虚拟文件系统,系统进程信息
/var variable files 增长文件,类似日志
/tmp temporaray files 临时文件,通常用于反复写读的目录
/usr user programs 常见操作命令和库及源码
/home home directories 存储用户
/boot boot loader files 程序引导文件
/lib system libraries 系统库文件
/opt optional add-on apps 附加应用程序
/mnt mount directory 临时安装目录,用于挂载文件系统
/media removable devices 挂载移动设备的临时目录
/srv service data 服务器数据

操作用户

简写 解析
cat /etc/passwd view all user infomation
cat /etc/group view all group
```
hao:x:1000:1000:乌班图,,,:/home/liuhao:/bin/bash
```
名称 解析
hao username
x password
1000 user ID
1000 group ID
乌班图,,, remarks
/home/liuhao home directory
/bin/bash shell

CURD/create/update/read/delete/用户

名称 解析
useradd -d <dir> <username> add a user and create the directory
passwd <username> change user password
userdel <username> delete user
userdel -r <username> delete user and delete file
id <username> query user
groupadd <groupname> add user group
groupdel <groupname> del user group
useradd -g <groupname> <username> add user to user-group
usermod -g <groupname> <username> change user to group

文件与权限

ls -l

drwxr-xr-x 2 root   root     4096 7月  30 17:21 -
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 公共的
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 模板
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 视频
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 图片
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 文档
lrwxrwxrwx 1 root   root        9 8月   1 20:32 我的天才女友 -> study.txt
drwxr-xr-x 2 liuhao root     4096 7月  27 16:37 下载
drwxr-xr-x 2 liuhao root     4096 7月  19 00:23 音乐
drwxr-xr-x 2 liuhao root     4096 7月  30 11:10 桌面
-rw-r--r-- 1 liuhao root     8980 7月  18 23:20 examples.desktop
-rw-r--r-- 1 liuhao root     1102 3月   3  2017 Release.key
-rw-r--r-- 1 liuhao liuhao    902 8月   1 19:59 sources.list
-rw-r--r-- 1 liuhao root   567814 7月  31 19:48 study.txt
文件类型/用户权限/同组权限/其他用户权限  文件链接数or子目录个数  拥有者 所在组  字节大小 最近修改时间 文件名

文件类型

d => directory
-=> file
l=> link
b => dev block files
c => character files
p => order shell files
s => socket files

用户权限类型

r:4 => read : view file
w:2 => write : change or delete file, create file
x:1 => excute : excute file

查找源链接文件

文件链接数为1为软链接

ls -i=> 展示文件的唯一id

find -inum id => 根据文件的id查找文件

文件授权

简写 解析
chmod change mode/修改状态
chmod xxx <file/dir> rwx=>7, rw=>6, rx=>5, wx=>3
chmod a/u/g/o +-= rwx <file-name> a=>all, u=>user, g=>group, o=>other
+-= +=>add , ->remove, ==>cover
chgrp change file group ownership
chgrp -R root <file/dir> change file owner be root-group
chown change file owner/group
chown -R root <file/dir> change file owner be root