此篇的目的在于怎样快速的记住繁琐的命令. 想要学习Linux 基础常用命令,个人认为首先要做的就是先到网上搜索相关内容的列表总结.然后在逐一学习.
一. 查找常用命令
例如, 根据维基百科, Linux常用命令可以分为以下几类:
那么我们就可以针对单个命令逐一的去相关网站查找用法.然后记住.
个人认为linux命令常常为命令表面意思的缩略语. 记住原本的大意可以更快的方便大家理解记忆. e.g. sudo - super user do
二. 日常记录
lshw
lshw - list hardware 显示硬件信息, 如需要查看网卡情况可以写作 lshw -C network
top
top - table of processes 查看 P:按%CPU使用率 T:按MITE+ M:按%MEM
参数名称 |
---|
PID - Process Id 进程ID |
USER: User Name |
PR:Priority The scheduling priority of the task. If you see `rt’ in this field, it means the task is running under real time scheduling priority. |
NI:Nice ValueThe nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task’s dispatch-ability. |
VIRT:Virtual Memory Size (KiB) |
RES: Resident Memory Size (KiB) |
SHR:Shared Memory Size (KiB) |
S:Process Status D = uninterruptible sleep I = idle R = running S = sleepingT = stopped by job control signalt = stopped by debugger during traceZ = zombie |
%CPU:CPU Usage |
%MEM:Memory Usage (RES) 进程使用的物理内存和总内存的百分比 |
TIME+:CPU Time, hundredthsThe same as TIME, but reflecting more granularity throughhundredths of a second. |
COMMAND:Display the command line used to start a task 进程启动命令名称 |
三. 常用命令分类记忆
(待补全用法, 解释)
1. 文件系统 File System
-
cat
cat - concatenate 它按顺序读取文件,将它们写入标准输出,常用
cat filename
来在terminal中显示文件内容
-n
显示行号-b
空白行不编号
cat f1 f2
输出 f1 和 f2 内容
cat f1 >f2
把f1输出到f2中,替换掉f2中所有内容
cat f1>>f2
把f1的内容添加到f2内容后,即所谓的 concatenate -
chmod
chmod : change mode 更新权限 , 777根用户,组用户,访客的读写全开放
chmod -R 777 filepath
(rwxrwxrwx)
chmod 755 filepath
(drwxr-xr-x) -
chown
chown - change owner 更换文件所有权
-
chgrp
chgrp - change group 更换文件组
-
cksum
cksum-checksum 校验
-
cmp
cmp -compare 对比文件是否一致(byte by byte)
有差异的话则会返回位置和行数 -
cp
cp -copy
cp [option]... source... directory
第一个是要复制文件, 第二个是要复制的位置 -
dd
dd -(待查) 用于读取、转换并输出数据
-
du
du -disk usage 的缩写
du -h
(便于用户查看,会自 动补全单位 K G M)du -s
(summary, 显示当前目录下的大小)
du -sh path
-s表示summarize的意思,即只列出一个总结的值
du -h --max-depth=1 path
–max-depth=n表示查看到第n层目录,设置为1时表示当前目录下的所有文件夹的大小 -
df
df - disk filesystem(在wiki上全称写作disk free) 显示磁盘使用状态
df -h
(h代表了 human-readable,显示G M K). df 着重于文件系统的占用情况,du 着重于当前目录下的磁盘使用情况 -
file
file -file 用来查看文件格式类型
file filename
显示文件类型 -
fuser
fuser -()显示哪些进程使用命名文件,soket 或文件系统
-
ln
ln -link 为某一个文件在另外一个位置建立一个同步的链接
ln -s source target
软连接 symbolic link, 以路径形式存在,类似于Windows快捷方式,可跨文件系统,可对不存在的文件进行链接,可对目录进行链接
ln source target
硬链接 以副本形式,不占用太多空间,不允许向目录进行链接,要在同一系统 -
ls
ls -list
-
mkdir
mkdir - make directory 新建路径
-
mv
mv -move 可以用作移动文件或者重命名
mv (option) old-name new-name
-
pax
pax-portable archive interchange pax命令读取,写入和写入归档文件成员和复制目录层次结构的列表
-
pwd
pwd -print working directory 写出工作路径
-
rm
rm - remove 此命令加上sudo之后,一定要小心使用, -r 也要小心使用
-
rmdir
rmdir - remove directory 删除路径
-
split
-
tee
-
touch
-
type
-
umask
2. 进程 Processes
-
at
-
bg
-
crontab
-
fg
-
kill
杀进程 kill -s 9 <线程号>
-
nice
-
ps
ps - process status
查看进程 ps -ef
查看某个进程 ps -ef |grep <进程名>
杀进程 kill -s 9 <线程号> -
pid
pid - process identification numbers
-
time
3. 用户环境 User Environment
- env
- exit
- logname
- mesg
- talk
- tput
- uname
- who
- write
4. 文本处理 Test Processing
- awk
- basement
- comm
- csplit
- cut
- diff
- dirname
- ed
- ex
- fold
- head
- iconv
- join
- m4
- more
- nl
- paste
- printf
- sed
- sort
- strings
- tail
- tr
- uniq
- vi
- wc
- xargs
5. 内核 Shell Builtins
-
alias
-
cd
cd -change directory
-
echo
-
test
-
unset
-
wait
6. 搜索 Searching
-
find
commands description find . -name testfile.txt
Find a file called testfile.txt in current and sub-directories. find /home -name *.jpg
Find all .jpg files in the /home and sub-directories. find . -type f -empty
Find an empty file within the current directory. find /home -user exampleuser -mtime 7 -iname ".db"
Find all .db files (ignoring text case) modified in the last 7 days by a user named exampleuser. -
grep
grep - globally search a regular expression and print
-
find . | wc -l
7. 文档
- man
man - manual 手册,
man python
会显示Python的应用手册
8. 软件开发 Software Development
- ar
- ctags
- lex
- make
- nm
- strip
- yacc
9. 杂项 Miscellaneous
- bc
- cal
cal - calendar 在terminal中显示日期
- expr
- lp
- od
- sleep
- true and false
– to be continue