Essential Linux/Unix Commands

本文详细介绍了16条常用的Unix命令,包括who、pwd、mkdir、rmdir、cd、ls、touch、cp、mv、rm、chmod、cal、file、sort、grep和man,解释了每个命令的功能和使用场景,如文件创建、目录操作、文件权限修改等。

1. who : The ‘$ who’ command displays all the users who have logged into the system currently.

2. pwd : The ‘$pwd’ command stands for ‘present working directory’ and as the name says,it displays the directory in which we are currently (directory is same as folder for Windows OS users).

3. mkdir : The ‘$ mkdir’ stands for ‘make directory’ and it creates a new directory.We have used ‘$ cd’ (which is discussed below) to get into the newly created directory and again on giving ‘$ pwd’ command,we are displayed with the new ‘newfolder’ directory.

4. rmdir : The ‘$ rmdir’ command deletes any directory we want to delete and you can remember it by its names ‘rmdir’ which stands for ‘remove directory’.

5. cd : The ‘$ cd’ command stands for ‘change directory’ and it changes your current directory to the ‘newfolder’ directory.You can understand this a double clicking a folder and then you do some stuff in that folder.

6. ls : The ‘$ ls’ command simply displays the contents of a directory.

7. touch : The ‘$ touch’ command creates a file(not directory) and you can simple add an extension such as .txt after it to make it a Text File.

8. cp : This ‘$ cp ‘ command stands for ‘copy’ and it simply copy/paste the file wherever you want to.In the above example we are copying a file ‘file.txt’ from the directory harssh to a new directory new.

9. mv : The ‘$ mv’ command stands for ‘move’ and it simply move a file from a directory to anothe directory.In the above example a file named ‘file.txt’ is being moved into a new directory ‘new’

10. rm : The ‘$ rm ‘ command for remove and the ‘-r’ simply forcibly deletes a file without prompting the user.Try ‘$ rm filename.txt’ at your terminal 

11. chmod : The ‘$ chmod’ command stands for change mode command.As there are many modes in Unix that can be used to manipulate files in the Unix environment.Basically there are 3 modes that we can use with the ‘chmod’ command
1. +w (stands for write and it changes file permissions to write)
2. +r (stands for read and it changes file permissions to read)
3. +x (generally it is used to make a file executable)

12. cal : The ‘$ cal’ means calendar and it simply display a calendar on to your screen.

13. file : The ‘$ file’ command displays the type of file.As i mentioned earlier linux treats everything as file so on
executing the command file on a directory(Downloads) it displays directory as the output
14. sort : As the name suggests the ‘$ sort’ sorts the contents of the file according to the ASCII rules.

15. grep : grep is an acronym for ‘globally search a regular expression and print it’.The ‘$ grep’ command searches the specified input fully(globally) for a match with the supplied pattern and displays it.
In the example, this would search for the word ‘picture’ in the file newsfile and if found,the lines containing it would be displayed on the screen.
$ grep picture newsfile

grep -l error cluster-2010*.log  // if you are grep log failure, it will only print filename if not true.
grep -n error cluster-2010*.log  // it will return line number which not true.

16. man : The ‘$ man’ command stands for ‘manual’ and it can display the in-built manual for most of the commands that we ever need.In the above example we can read about the ‘$ pwd’ command.
$ man pwd
17. lpr : The ‘$ lpr’ command send a file to the printer for printing.
$ lpr new.txt
18. passwd : The ‘$ passwd’ command simply changes the password of the user.In above case ‘harssh’ is the user.
$ passwd
Output: Changing password for harssh.
(current) UNIX password:
19. clear : The ‘$ clear’ command is used to clean up the terminal so that you can type with more accuracy 
$ clear

转载于:https://www.cnblogs.com/grainy/p/7215722.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值