Linux笔记(5):UNIX 命令
来源:互联网 发布:淘宝买iphone6s哪家好 编辑:程序博客网 时间:2024/05/16 12:35
1.
1.1 Listing files and directories
ls (list)
1.2 Making Directories
mkdir (make directory)
1.3 Changing to a different directory
cd (change directory)
1.4 The directories . and ..
% cd . % cd ..
1.5 Pathnames(路径名)
pwd (print working directory)
1.6新建文件
touch a.txt
2.
2.1 Copying Files
cp (copy)
% cp /vol/examples/tutorial/science.txt .
Note: Don’t forget the dot . at the end. Remember, in UNIX, the dot means the current directory.
2.2 Moving files
mv (move) mv file1 file2 moves (or renames) file1 to file2 % mv science.bak backups/.
2.3 Removing files and directories
rm (remove)(删除文件)rmdir (remove directory)(删除空文件夹)
2.4 Displaying the contents of a file on the screen
clear (clear screen) % clear cat (concatenate) % cat science.txt less % less science.txt head % head science.txt % head -5 science.txt tail % tail science.txt
2.5 Searching the contents of a file
2.5.1 less
% less science.txt
then, still in less, type a forward slash [/] followed by the word to search
/science
2.5.2 grep
% grep -i science science.txt
2.5.3 wc (word count)
% grep -i science science.txt
A handy little utility is the wc command, short for word count. To do a word count on science.txt, type
% wc -w science.txt
To find out how many lines the file has, type
% wc -l science.txt
Linux中more和less命令用法 http://www.cnblogs.com/aijianshi/p/5750911.html
3.
3.1 Redirection (重定向)
% cat
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ catdddddd
3.2 Redirecting the Output(重定向输出)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat > list1pearbananaapple
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat list1pearbananaapple
3.2.1 Appending to a file (附加到文件)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat >> list1peachgrapeorangekuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat list1pearbananaapplepeachgrapeorange
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat > list2orangekuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat list1 list2 >biglistkuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat biglistpearbananaapplepeachgrapeorangeorange
3.3 Redirecting the Input (重定向输入)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sort(排序)dogcatbirdape # ^D (Control D to stop) apebirdcatdog
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sort < biglist #(对列表biglist排序)applebananagrapeorange# ^D (Control D to stop) orangepeachpear
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sort < biglist > slist #(对biglist排序并保存到slist)kuo@kuo-Inspiron-7420:~/unixstuff/backups$ cat slistapplebananagrapeorangeorangepeachpear
3.4 Pipes
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ whokuo :0 2017-09-20 14:32 (:0)kuo pts/1 2017-09-20 14:41 (:0)
4.
4.1 Wildcards(通配符 *)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls list*list1 list2kuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls *listbiglist slistkuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls ?listslist
4.2 Filename conventions (文件名约定)
4.3 Getting Help
% man wc % whatis wc #(gives a one-line description of the command, but omits any information about options etc.)% apropos keyword
5.
5.1 File system security (access rights) (文件系统安全(访问权限))
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls -l总用量 28-rw-rw-r-- 1 kuo kuo 55 9月 20 16:51 a.txt-rw-rw-r-- 1 kuo kuo 6 9月 20 16:37 a.txt~-rw-rw-r-- 1 kuo kuo 44 9月 20 18:28 biglist-rw-rw-r-- 1 kuo kuo 0 9月 20 16:01 c.tat-rw-rw-r-- 1 kuo kuo 37 9月 20 18:27 list1-rw-rw-r-- 1 kuo kuo 7 9月 20 18:28 list2-rw-rw-r-- 1 kuo kuo 88 9月 20 18:34 names.txt-rw-rw-r-- 1 kuo kuo 44 9月 20 18:32 slist
5.2 Changing access rights(更改访问权限)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ chmod go-rwx biglistkuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls -l总用量 28-rw-rw-r-- 1 kuo kuo 55 9月 20 16:51 a.txt-rw-rw-r-- 1 kuo kuo 6 9月 20 16:37 a.txt~-rw------- 1 kuo kuo 44 9月 20 18:28 biglist-rw-rw-r-- 1 kuo kuo 0 9月 20 16:01 c.tat-rw-rw-r-- 1 kuo kuo 37 9月 20 18:27 list1-rw-rw-r-- 1 kuo kuo 7 9月 20 18:28 list2-rw-rw-r-- 1 kuo kuo 88 9月 20 18:34 names.txt-rw-rw-r-- 1 kuo kuo 44 9月 20 18:32 slist
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ chmod a+rw biglistkuo@kuo-Inspiron-7420:~/unixstuff/backups$ ls -l总用量 28-rw-rw-r-- 1 kuo kuo 55 9月 20 16:51 a.txt-rw-rw-r-- 1 kuo kuo 6 9月 20 16:37 a.txt~-rw-rw-rw- 1 kuo kuo 44 9月 20 18:28 biglist-rw-rw-r-- 1 kuo kuo 0 9月 20 16:01 c.tat-rw-rw-r-- 1 kuo kuo 37 9月 20 18:27 list1-rw-rw-r-- 1 kuo kuo 7 9月 20 18:28 list2-rw-rw-r-- 1 kuo kuo 88 9月 20 18:34 names.txt-rw-rw-r-- 1 kuo kuo 44 9月 20 18:32 slist
5.3 Processes and Jobs (流程和工作)
1.PS 显示正在工作的进程
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ ps PID TTY TIME CMD 2533 pts/1 00:00:00 bash 7467 pts/1 00:00:00 ps
2.Running background processes(运行后台进程)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 10#前台运行休眠10skuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 10 &[1] 7491#后台运行休眠10skuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 1000hhffff#后台运行休眠10s^Z[1] 已完成 sleep 10#Crtl+z 停止前台运行[2]+ 已停止 sleep 1000kuo@kuo-Inspiron-7420:~/unixstuff/backups$ bg[2]+ sleep 1000 &#bg 转到后台运行
5.4 Listing suspended and background processes (列出暂停和后台进程)
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 1000 ^Z# ^Z 是暂停前台进程[1]+ 已停止 sleep 1000kuo@kuo-Inspiron-7420:~/unixstuff/backups$ bg# bg 后台运行进程[1]+ sleep 1000 &kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs# jobs 显示后台进程[1]+ 运行中 sleep 1000 &kuo@kuo-Inspiron-7420:~/unixstuff/backups$ fg %1# fg%1 将后台进程1转到前台sleep 1000dddddd^Z# ^Z 是暂停进程[1]+ 已停止 sleep 1000kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs[1]+ 已停止 sleep 1000kuo@kuo-Inspiron-7420:~/unixstuff/backups$ bg[1]+ sleep 1000 &kuo@kuo-Inspiron-7420:~/unixstuff/backups$ fg %1sleep 1000^C# ^C是杀死进程kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobskuo@kuo-Inspiron-7420:~/unixstuff/backups$
5.5 Killing a process(杀死一个进程)
1.
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 100 ^Z[1]+ 已停止 sleep 100kuo@kuo-Inspiron-7420:~/unixstuff/backups$ bg[1]+ sleep 100 &kuo@kuo-Inspiron-7420:~/unixstuff/backups$ kill %1# kill%1 杀死进程1kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs[1]+ 已终止 sleep 100kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs
2.
kuo@kuo-Inspiron-7420:~/unixstuff/backups$ sleep 100 &[1] 7579kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs[1]+ 运行中 sleep 100 &kuo@kuo-Inspiron-7420:~/unixstuff/backups$ ps PID TTY TIME CMD 2533 pts/1 00:00:00 bash 7579 pts/1 00:00:00 sleep 7580 pts/1 00:00:00 pskuo@kuo-Inspiron-7420:~/unixstuff/backups$ kill 7579# kill 7579 使用(PID)号杀死进程kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobs[1]+ 已终止 sleep 100kuo@kuo-Inspiron-7420:~/unixstuff/backups$ jobskuo@kuo-Inspiron-7420:~/unixstuff/backups$ ps PID TTY TIME CMD 2533 pts/1 00:00:00 bash 7581 pts/1 00:00:00 pskuo@kuo-Inspiron-7420:~/unixstuff/backups$
6.环境变量
% echo $OSTYPE
More examples of environment variables are
USER (your login name)HOME (the path name of your home directory)HOST (the name of the computer you are using)ARCH (the architecture of the computers processor)DISPLAY (the name of the computer screen to display X windows)PRINTER (the default printer to send print jobs)PATH (the directories the shell should search to find a command)
转自:UNIX Tutorial for Beginners
阅读全文
0 0
- Linux笔记(5):UNIX 命令
- Unix&Linux笔记(5)
- JAVA学习笔记(复习)-----1、 基本Linux/Unix命令
- 常用linux(unix)命令
- Unix & Linux基础笔记(5)
- Unix & Linux笔记(6)
- Unix & Linux笔记(8)
- Unix & Linux 笔记(9)
- Unix & Linux 笔记(10)
- Unix & Linux笔记(11)
- Unix & Linux 笔记(12)
- Unix & Linux笔记(14)
- Unix & Linux笔记(15)
- Unix & Linux笔记(16)
- Unix & Linux笔记(17)
- 初学unix命令笔记
- Unix 命令学习笔记
- Linux/UNIX脚本编程学习笔记(0812)---set命令
- JVM结构、GC工作机制详解
- 《Unity3D网络游戏实战》学习笔记--Unity3D软件安装之error:CS0246The type or namespace name 'PostEffectsBase' could not
- SQLite数据库之使用
- 干支、生肖查询器 v3.0(增加公元前年份的查询)
- 这3种界面交互设计用户并不喜欢
- Linux笔记(5):UNIX 命令
- Ionic之如何将上级页面的数据传递给下级界面
- SCUT Training 20170920 Problem M
- <安彦>深入浅出多线程技术
- Spring MVC @ModelAttribute 详解
- Struts2-02-OGNL及值栈
- 使用java进行文件编码转换
- Cesium应用篇:2影像服务(下)
- 时钟