50个最常用的UNIX Linux命令(结合实例)
UNIX系统常用命令

UNIX系统常用命令UNIX系统常用命令格式:command [flags] [argument1] [argument2] ...其中flags以-开始,多个flags可用一个-连起来,如ls -l -a 与ls -la相同。
根据命令的不同,参数分为可选的或必须的;所有的命令从标准输入接受输入,输出结果显示在标准输出,而错误信息则显示在标准错误输出设备。
可使用重定向功能对这些设备进行重定向。
命令在正常执行结果后返回一个0值,如果命令出错可未完全完成,则返回一个非零值(在shell中可用变量$?查看). 在shell script中可用此返回值作为控制逻辑的一部分。
注:不同的UNIX版本的flags可能有所不同。
1、与用户相关的命令1.1 login(在LINUX Redhat下此命令功能与Solaris/BSD不同,执行login会退出当前任务).login:Password:相关文件:在下面的这些文件中设定shell运行时必要的路径,终端类型,其他变量或特殊程序.$HOME/.profile (Bourne shell, sh, bash)$HOME/.cshrc (csh, tcsh)$HOME/.tcshrc (tcsh)/etc/passwd文件中列出每个用户的shell/etc/csh.cshrc/etc/csh.login/etc/profile (Bourne shell, bash)/etc/login (Bourne shell, bash)csh: /etc/csh.cshrc和$HOME/.cshrc每次执行都会读取,而/etc/csh.login和$HOME/.login只有注册shell才执行修改相应文件后使用 source .cshrc使能相关修改,如果修改了path则还需使用rehash刷新可执行文件hash表。
tcsh: $HOME/.tcshrc, 没有些文件读取.cshrcsh: /etc/profile和$HOME/.profile注册shellbash: /etc/profile和$HOME/.bash_profile注册shell读取.bashrc交互式非注册shell才读取。
linux常用100个命令

linux常用100个命令以下是常用的100个Linux命令:1. ls - 列出当前目录中的文件和文件夹2. cd - 改变当前工作目录3. pwd - 显示当前工作目录的路径4. mkdir - 创建一个新的目录5. rmdir - 删除一个空的目录6. touch - 创建一个新的空文件7. cp - 复制文件或目录8. mv - 移动或重命名文件或目录9. rm - 删除文件或目录10. cat - 显示文件内容11. less - 逐行显示文件内容12. head - 显示文件的前几行内容13. tail - 显示文件的后几行内容14. grep - 在文件中搜索匹配的文本15. find - 在文件系统中搜索文件16. chmod - 改变文件或目录的权限17. chown - 改变文件或目录的所有者18. chgrp - 改变文件或目录的所属组19. du - 显示目录或文件的磁盘使用情况20. df - 显示文件系统的磁盘使用情况21. file - 显示文件的类型22. ln - 创建一个硬链接或符号链接23. mount - 挂载文件系统24. umount - 卸载文件系统25. tar - 创建或解压归档文件26. gzip - 压缩文件27. gunzip - 解压缩文件28. wget - 下载文件29. curl - 通过URL获取或发送数据30. ssh - 远程登录到另一台计算机31. scp - 在本地主机和远程主机之间复制文件32. ping - 测试与另一台计算机的连接33. ifconfig - 显示或配置网络接口34. netstat - 显示网络连接、路由表等信息35. iptables - 配置防火墙规则36. ps - 显示当前运行的进程37. top - 显示系统中运行的进程和资源使用情况38. kill - 终止正在运行的进程39. service - 启动、停止或重启系统服务40. systemctl - 管理系统服务41. uname - 显示系统信息42. date - 显示或设置系统时间和日期43. history - 显示或搜索命令历史记录44. which - 显示可执行文件的路径45. echo - 显示文本或变量的值46. export - 设置环境变量47. source - 执行一个脚本文件48. alias - 创建命令别名49. sed - 流编辑器,用于文件内容的替换和修改50. awk - 文本处理工具,用于提取和处理文本数据51. sort - 对文本进行排序52. uniq - 删除重复的行53. diff - 比较两个文件的差异54. tr - 替换、删除或压缩字符55. cut - 从文本中提取字段56. paste - 将多个文件的行合并成一行57. join - 根据共同的字段将两个文件合并58. split - 将文件分割成多个较小的文件59. grep -v - 显示不匹配的文本行60. grep -c - 统计匹配的文本行数61. grep -i - 忽略大小写进行匹配62. grep -r - 递归地搜索目录中的文件63. grep -w - 匹配整个单词而不是部分匹配64. grep -A - 显示匹配行及其后面的几行65. grep -B - 显示匹配行及其前面的几行66. grep -C - 显示匹配行及其前后的几行67. awk '{print $1}' - 打印每行的第一个字段68. awk '{print $NF}' - 打印每行的最后一个字段69. awk '/pattern/{print}' - 打印匹配模式的行70. awk '/pattern/{print $2}' - 打印匹配模式的第二个字段71. awk '{sum+=$1} END {print sum}' - 计算第一列的总和72. awk '{if ($1 > 10) print}' - 打印第一列大于10的行73. awk '{if ($1 > 10) print $2}' - 打印第一列大于10的第二个字段74. awk '{print NR, $0}' - 打印行号和整行内容75. awk '{for (i=1; i<=NF; i++) print $i}' - 打印每个字段76. sed 's/pattern/replace/' - 替换匹配的文本77. sed '/pattern/d' - 删除匹配的文本行78. sed '/pattern/s/old/new/' - 在匹配的文本行中替换文本79. sed '/pattern/!d' - 删除不匹配的文本行80. sed '1d' - 删除第一行81. sed '$d' - 删除最后一行82. sed -n '1,5p' - 打印前5行83. sed -n '5,$p' - 打印从第5行到最后一行84. sed -n '/pattern/p' - 打印匹配的文本行85. sed -n '/pattern/{p;q;}' - 打印匹配的文本行并退出86. sort -n - 对数字进行排序87. sort -r - 逆序排序88. sort -u - 去除重复的行89. sort -k2 - 按第二个字段进行排序90. sort -t',' -k2 - 使用逗号作为分隔符,按第二个字段进行排序91. uniq -c - 统计重复的行数92. uniq -d - 只显示重复的行93. uniq -u - 只显示不重复的行94. diff -u - 显示详细的差异95. diff -r - 递归比较目录中的文件96. tr 'a-z' 'A-Z' - 将小写字母转换为大写字母97. tr -d '[:digit:]' - 删除所有数字98. tr -s ' ' - 合并连续的空格为一个空格99. cut -d',' -f1 - 使用逗号作为分隔符,打印第一个字段100. cut -c1-5 - 打印每行的前五个字符这些命令是Linux中最常用的命令之一,可以帮助您在终端中进行文件和文本处理、系统管理、网络配置等操作。
linux常用命令及示范

Linux常用命令及示范Linux是一种开源的操作系统,它具有高效、稳定、安全等优点,广泛应用于服务器、嵌入式设备、云计算等领域。
Linux系统提供了丰富的命令行工具,可以方便地对系统进行管理、配置、监控和调试。
本文将介绍Linux常用的一些命令,包括文件操作、目录操作、进程管理、网络管理、系统管理和其他实用的命令,并给出一些具体的示例,帮助读者掌握Linux命令的基本用法和技巧。
一、文件操作命令文件是Linux系统中最基本的单位,它可以是文本文件、二进制文件、设备文件等。
Linux系统提供了一些命令,可以对文件进行创建、删除、复制、移动、重命名、查看、编辑等操作。
下面介绍一些常用的文件操作命令。
1. touch命令touch命令的作用是创建一个空文件或者修改一个已有文件的时间戳。
它的基本语法是:touch [选项] 文件名其中,选项可以是:-a:只修改访问时间-c:如果文件不存在,不创建新文件-m:只修改修改时间-r:把指定文件的时间戳复制给另一个文件-t:指定修改时间,格式为[[CC]YY]MMDDhhmm[.ss]例如:# 创建一个空文件test.txttouch test.txt# 修改test.txt的访问时间和修改时间为当前时间touch test.txt# 修改test.txt的访问时间为2021年4月1日10:00:00touch -a -t 202104011000.00 test.txt# 把test.txt的时间戳复制给test2.txttouch -r test.txt test2.txt2. rm命令rm命令的作用是删除一个或多个文件或目录。
它的基本语法是:rm [选项] 文件或目录其中,选项可以是:-f:强制删除,忽略不存在的文件或目录,不提示确认-i:交互式删除,删除前提示确认-r:递归删除,删除目录及其子目录和文件例如:# 删除一个文件test.txtrm test.txt# 删除一个目录test,并提示确认rm -ir test# 强制删除一个目录test及其子目录和文件,不提示确认rm -rf test3. cp命令cp命令的作用是复制一个或多个文件或目录。
lunix命令大全

UNIX命令大全UNIX常用命令:下述命令参考包含94个UN IX最常用的快速总结。
apropos用途:apropos查找使用说明的名称。
举例:apropos print(等价于man-k prink)。
arch用途:arch获得机器体系结构的描述信息。
举例:arch。
下面是arch输出的结果:sun4将这个命令与u n ame进行比较。
ash用途:ash是外壳,只用于某些系统。
举例:ash。
这个命令启动a sh外壳的一个实例。
at用途:at用于确定命令执行的时刻。
举例:at 9:00am Decembe r 31。
awk用途:awk是一种模式扫描和执行语言。
举例:awk\'{print $1}\'file.txt。
这个命令执行后将打印出fi le.txt的第一个区域。
bash用途:bash是GNU Bourne-A gain外壳。
举例:bash[options]。
这个命令启动b a sh外壳,它是一个增强的和sh兼容的外壳。
bash的提示符为$。
biff用途:biff通知你是否收到了邮件。
举例:biffy。
这个命令叫bi f f通知你新邮件什么时候到达(注意,要想让biff工作,你必须同时运行sendmai l)。
cancel用途:cancel取消挂起的打印作业。
举例:cancel23。
这个命令取消23号打印作业。
cal用途:cal显示无格式文本日历。
举例:cal。
以下是命令执行后输出的列表:August 1998cat用途:cat将文件连接在一起并显示这些文件中的内容。
举例:cat myfile.txt。
这个命令执行后显示myfi le.txt中的内容。
cc用途:cc是用于许多系统的C编译器。
举例:cc myfile.c -o myfile。
这个命令执行后对myfil e.c源文件进行编译并输出一个名为myf i le的可执行文件。
linux必须知道的60个常用命令

linux必学的60个命令来源: ChinaUnix博客日期: 2008.01.28 18:50 (共有条评论) 我要评论linux必学的60个命令Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作、文件存取、目录操作、进程管理、文件权限设定等。
所以,在Linux系统上工作离不开使用系统提供的命令。
要想真正理解Linux系统,就必须从Linux命令学起,通过基础的命令学习可以进一步理解Linux系统。
不同Linux发行版的命令数量不一样,但Linux发行版本最少的命令也有200多个。
这里笔者把比较重要和使用频率最多的命令,按照它们在系统中的作用分成下面六个部分一一介绍。
◆ 安装和登录命令:login、shutdown、halt、reboot、install、mount、umount、chsh、exit、last;◆ 文件处理命令:file、mkdir、grep、dd、find、mv、ls、diff、cat、ln;◆ 系统管理相关命令:df、top、free、quota、at、lp、adduser、groupadd、kill、crontab;◆ 网络操作命令:ifconfig、ip、ping、netstat、telnet、ftp、route、rlogin、rcp、finger、mail、nslookup;◆ 系统安全相关命令:passwd、su、umask、chgrp、chmod、chown、chattr、sudo ps、who;◆ 其它命令:tar、unzip、gunzip、unarj、mtools、man、unendcode、uudecode。
本文以Mandrake Linux 9.1(Kenrel 2.4.21)为例,介绍Linux下的安装和登录命令。
immortality按:请用ctrl+f在本页中查找某一部分的内容或某一命令的用法。
Linux必学的60个命令(1)-安装与登陆命令login1.作用login的作用是登录系统,它的使用权限是所有用户。
常用的linux命令 文档

常用的linux命令文档常用的Linux命令文档Linux操作系统是一种非常强大和灵活的操作系统,广泛应用于服务器和嵌入式系统中。
作为一名Linux系统管理员或者开发者,掌握常用的Linux 命令是至关重要的。
本文旨在提供一份常用的Linux命令文档,涵盖了从基本命令到高级命令的应用和使用。
1. 文件和目录操作命令1.1 ls命令:列出当前目录下的文件和子目录。
1.2 cd命令:切换当前工作目录。
1.3 mkdir命令:创建新的目录。
1.4 cp命令:复制文件或目录。
1.5 mv命令:移动文件或目录。
1.6 rm命令:删除文件或目录。
1.7 touch命令:创建一个新文件。
1.8 cat命令:显示文件内容或者将几个文件合并成一个文件。
1.9 echo命令:将指定的文本输出到终端或者文件。
2. 文件查找和搜索命令2.1 find命令:根据指定的条件在文件系统中查找文件。
2.2 grep命令:在文件或者输入中查找匹配的行。
2.3 locate命令:在系统的数据库中查找文件。
2.4 which命令:查找可执行文件的路径。
2.5 whereis命令:查找二进制程序、源代码和man页文件的路径。
3. 文件权限和权限管理命令3.1 chmod命令:修改文件或目录的权限。
3.2 chown命令:修改文件或目录的所有者。
3.3 chgrp命令:修改文件或目录的所属组。
3.4 passwd命令:修改用户密码。
4. 系统管理命令4.1 top命令:实时显示各种系统资源的使用情况。
4.2 ps命令:查看当前运行的进程。
4.3 kill命令:终止指定的进程。
4.4 service命令:启动、停止和重启系统服务。
4.5 systemctl命令:管理系统的Systemd服务。
5. 网络操作命令5.1 ifconfig命令:查看和设置网络接口配置。
5.2 ping命令:测试主机之间的连通性。
5.3 ssh命令:通过SSH协议登录到远程主机。
UNIX操作系统命令大全

UNIX操作系统命令大全1. ls:列出当前目录中的文件和目录。
2. cd:切换当前工作目录。
3. pwd:显示当前工作目录的路径。
4. mkdir:创建一个新目录。
5. rmdir:删除一个空目录。
6. cp:复制文件或目录。
7. mv:移动或重命名文件或目录。
8. rm:删除文件或目录。
9. touch:创建一个新文件。
10. cat:连接文件并打印到标准输出设备上。
11. less:逐页显示文件内容。
12. head:显示文件的开头几行。
13. tail:显示文件的末尾几行。
14. grep:在文件中查找匹配的字符串。
15. find:从指定目录开始递归地查找文件。
16. tar:打包和压缩文件。
17. unzip:解压缩文件。
18. chmod:更改文件的权限。
19. chown:更改文件的所有者。
20. chgrp:更改文件的所属组。
21. ps:显示当前运行的进程。
22. top:动态显示系统资源使用情况。
23. kill:终止一个进程。
24. ssh:使用安全外壳协议远程登录到另一台计算机。
25. scp:通过安全外壳协议在本地计算机和远程计算机之间传输文件。
26. ping:测试与另一台计算机的网络连接。
27. ifconfig:显示和配置网络接口。
28. netstat:显示网络连接、路由表和网络接口统计信息。
29. hostname:显示或设置主机名。
30. whoami:显示当前登录的用户。
31. su:切换到另一个用户身份。
32. sudo:以超级用户的身份执行命令。
33. date:显示或设置系统日期和时间。
35. df:显示文件系统的磁盘使用情况。
36. du:显示目录或文件的磁盘使用情况。
37. tar:创建备份文件或将备份文件释放到系统中。
38. gzip:使用GNU的zip压缩程序压缩文件。
39. gunzip:解压文件。
40. zip:创建一个zip文件。
41. uname:显示系统信息。
100个常用的linux命令

100个常用的linux命令100个常用的Linux命令Linux作为一种常用的操作系统,拥有丰富的命令用于管理和操作系统。
本文将介绍100个常用的Linux命令,并对其功能和使用方法进行详细的说明和解释。
1. ls:列出当前目录下的文件和文件夹。
2. cd:切换当前目录。
3. pwd:显示当前工作目录的绝对路径。
4. mkdir:创建新的目录。
5. rm:删除文件或目录。
6. cp:复制文件或目录。
7. mv:移动文件或目录。
8. touch:创建新的空文件。
9. cat:查看文件内容。
10. more:逐页显示文件内容。
11. less:逐行显示文件内容。
12. grep:在文件中搜索指定的字符串。
13. find:在文件系统中搜索文件。
14. tar:打包和解压文件。
15. gzip:压缩文件。
16. gunzip:解压缩文件。
17. chown:修改文件的所有者。
18. chmod:修改文件的权限。
19. chgrp:修改文件的所属组。
20. ps:显示当前运行的进程。
21. top:实时显示系统的运行情况。
22. kill:终止指定的进程。
23. ifconfig:查看和配置网络接口。
24. ping:测试网络连接。
25. ssh:远程登录到其他主机。
26. scp:在本地主机和远程主机之间复制文件。
27. wget:下载文件。
28. curl:通过URL传输数据。
29. head:显示文件的前几行。
30. tail:显示文件的后几行。
31. du:查看文件或目录的磁盘使用情况。
32. df:查看文件系统的磁盘空间使用情况。
33. free:查看内存的使用情况。
34. uname:显示系统信息。
35. who:显示当前登录的用户。
36. su:切换用户身份。
37. sudo:以管理员身份执行命令。
38. history:查看命令历史记录。
39. man:查看命令的帮助文档。
40. info:查看命令的详细信息。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
本文提供了50最常用的命令在Linux / UNIX的实际例子。
收藏这篇文章供日后参考。
Did I miss any frequently used Linux commands? Leave a comment and let me know.1. tar command examplesCreate a new tar archive.$ tar cvf archive_name.tar dirname/Extract from an existing tar archive.$ tar xvf archive_name.tarView an existing tar archive.$ tar tvf archive_name.tarMore tar examples: The Ultimate Tar Command Tutorial with 10 Practical Examples2. grep command examplesSearch for a given string in a file (case in-sensitive search).$ grep -i "the" demo_filePrint the matched line, along with the 3 lines after it.$ grep -A 3 -i "example" demo_textSearch for a given string in all files recursively$ grep -r "ramesh" *More grep examples: Get a Grip on the Grep! – 15 Practical Grep Command Examples3. find command examplesFind files using file-name ( case in-sensitve find)# find -iname "MyCProgram.c"Execute commands on files found by the find command$ find -iname "MyCProgram.c" -exec md5sum {} \;Find all empty files in home directory# find ~ -emptyMore find examples: Mommy, I found it! —15 Practical Linux Find Command Examples4. ssh command examplesLogin to remote hostssh -l jsmith Debug ssh clientssh -v -l jsmith Display ssh client version$ ssh -VOpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003More ssh examples: 5 Basic Linux SSH Client Commands5. sed command examplesWhen you copy a DOS file to Unix, you could find \r\n in the end of each line. This example converts the DOS file format to Unix file format using sed command.$sed 's/.$//' filenamePrint file content in reverse order$ sed -n '1!G;h;$p' thegeekstuff.txtAdd line number for all non-empty-lines in a file$ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /'More sed examples: Advanced Sed Substitution Examples6. awk command examplesRemove duplicate lines using awk$ awk '!($0 in array) { array[$0]; print }' tempPrint all lines from /etc/passwd that has the same uid and gid$awk -F ':' '$3==$4' passwd.txtPrint only specific field from a file.$ awk '{print $2,$5;}' employee.txtMore awk examples: 8 Powerful Awk Built-in Variables –FS, OFS, RS, ORS, NR, NF, FILENAME, FNR7. vim command examplesGo to the 143rd line of file$ vim +143 filename.txtGo to the first match of the specified$ vim +/search-term filename.txtOpen the file in read only mode.$ vim -R /etc/passwdMore vim examples: How To Record and Play in Vim Editor8. diff command examplesIgnore white space while comparing.# diff -w name_list.txt name_list_new.txt2c2,3< John Doe --- > John M Doe> Jason BourneMore diff examples: Top 4 File Difference Tools on UNIX / Linux – Diff, Colordiff, Wdiff, Vimdiff9. sort command examplesSort a file in ascending order$ sort names.txtSort a file in descending order$ sort -r names.txtSort passwd file by 3rd field.$ sort -t: -k 3n /etc/passwd | more10. export command examplesTo view oracle related environment variables.$ export | grep ORACLEdeclare -x ORACLE_BASE="/u01/app/oracle"declare -x ORACLE_HOME="/u01/app/oracle/product/10.2.0"declare -x ORACLE_SID="med"declare -x ORACLE_TERM="xterm"To export an environment variable:$ export ORACLE_HOME=/u01/app/oracle/product/10.2.011. xargs command examplesCopy all images to external hard-drive# ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory Search all jpg images in the system and archive it.# find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz Download all the URLs mentioned in the url-list.txt file# cat url-list.txt | xargs wget –c12. ls command examplesDisplay filesize in human readable format (e.g. KB, MB etc.,)$ ls -lh-rw-r----- 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr $ ls -ltrVisual Classification of Files With Special Characters Using ls -F $ ls -FMore ls examples: Unix LS Command: 15 Practical Examples13. pwd commandpwd is Print working directory. What else can be said about the good old pwd who has been printing the current directory name for ages.14. cd command examplesUse “cd -” to toggle between the last two directoriesUse “shopt -s cds pell” to automatically correct mistyped directory names on cdMore cd examples: 6 Awesome Linux cd command Hacks15. gzip command examplesTo create a *.gz compressed file:$ gzip test.txtTo uncompress a *.gz file:$ gzip -d test.txt.gzDisplay compression ratio of the compressed file using gzip -l$ gzip -l *.gzcompressed uncompressed ratio uncompressed_name23709 97975 75.8% asp-patch-rpms.txt16. bzip2 command examplesTo create a *.bz2 compressed file:$ bzip2 test.txtTo uncompress a *.bz2 file:bzip2 -d test.txt.bz2More bzip2 examples: BZ is Eazy! bzip2, bzgrep, bzcmp, bzdiff, bzcat, bzless, bzmore examples17. unzip command examplesTo extract a *.zip compressed file:$ unzip test.zipView the contents of *.zip file (Without unzipping it):$ unzip -l jasper.zipArchive: jasper.zipLength Date Time Name-------- ---- ---- ----40995 11-30-98 23:50 META-INF/MANIFEST.MF32169 08-25-98 21:07 classes_15964 08-25-98 21:07 classes_names10542 08-25-98 21:07 classes_ncomp18. shutdown command examplesShutdown the system and turn the power off immediately.# shutdown -h nowShutdown the system after 10 minutes.# shutdown -h +10Reboot the system using shutdown command.# shutdown -r nowForce the filesystem check during reboot.# shutdown -Fr now19. ftp command examplesBoth ftp and secure ftp (sftp) has similar commands. To connect to a remote server and download multiple files, do the following.$ ftp IP/hostnameftp> mget *.htmlTo view the file names located on the remote server before downloading, mls ftp command as shown below.ftp> mls *.html -/ftptest/features.html/ftptest/index.html/ftptest/othertools.html/ftptest/samplereport.html/ftptest/usage.htmlMore ftp examples: FTP and SFTP Beginners Guide with 10 Examples20. crontab command examplesView crontab entry for a specific user# crontab -u john -lSchedule a cron job every 10 minutes.*/10 * * * * /home/ramesh/check-disk-spaceMore crontab examples: Linux Crontab: 15 Awesome Cron Job Examples 21. service command examplesService command is used to run the system V init scripts. i.e Instead of calling the scripts located in the /etc/init.d/ directory with their full path, you can use the service command.Check the status of a service:# service ssh statusCheck the steatus of all the services.service --status-allRestart a service.# service ssh restart22. ps command examplesps command is used to display information about the processes that are running in the system.While there are lot of arguments that could be passed to a ps command, following are some of the common ones.To view current running processes.$ ps -ef | moreTo view current running processes in a tree structure. H option stands for process hierarchy.$ ps -efH | more23. free command examplesThis command is used to display the free, used, swap memory available in the system.Typical free command output. The output is displayed in bytes.$ freetotal used free shared buffers cachedMem: 3566408 1580220 1986188 0 203988 902960-/+ buffers/cache: 473272 3093136Swap: 4000176 0 4000176If you want to quickly check how many GB of RAM your system has use the -g option. -b option displays in bytes, -k in kilo bytes, -m in mega bytes.$ free -gtotal used free shared buffers cachedMem: 3 1 1 0 0 0-/+ buffers/cache: 0 2Swap: 3 0 3If you want to see a total memory ( including the swap), use the -t switch, which will display a total line as shown below.ramesh@ramesh-laptop:~$ free -ttotal used free shared buffers cachedMem: 3566408 1592148 1974260 0 204260 912556-/+ buffers/cache: 475332 3091076Swap: 4000176 0 4000176Total: 7566584 1592148 597443624. top command examplestop command displays the top processes in the system ( by default sorted by cpu usage ). To sort top output by any column, Press O (upper-case O) , which will display all the possible columns that you can sort by as shown below.Current Sort Field: P for window 1:DefSelect sort field via field letter, type any other key to returna: PID = Process Id v: nDRT = Dirty Pages countd: UID = User Id y: WCHAN = Sleeping in Functione: USER = User Name z: Flags = Task Flags ........To displays only the processes that belong to a particular user use -u option. The following will show only the top processes that belongs to oracle user.$ top -u oracleMore top examples: Can You Top This? 15 Practical Linux Top Command Examples25. df command examplesDisplays the file system disk space usage. By default df -k displays output in bytes.$ df -kFilesystem 1K-blocks Used Available Use% Mounted on/dev/sda1 29530400 3233104 24797232 12% //dev/sda2 120367992 50171596 64082060 44% /homedf -h displays output in human readable form. i.e size will be displayed in GB’s.ramesh@ramesh-laptop:~$ df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 29G 3.1G 24G 12% //dev/sda2 115G 48G 62G 44% /homeUse -T option to display what type of file system.ramesh@ramesh-laptop:~$ df -TFilesystem Type 1K-blocks Used Available Use% Mounted on/dev/sda1 ext4 29530400 3233120 24797216 12% //dev/sda2 ext4 120367992 50171596 64082060 44% /home26. kill command examplesUse kill command to terminate a process. First get the process id using ps -ef command, then use kill -9 to kill the running Linux process as shown below. You can also use killall, pkill, xkill to terminate a unix process.$ ps -ef | grep vimramesh 7243 7222 9 22:43 pts/2 00:00:00 vim$ kill -9 7243More kill examples: 4 Ways to Kill a Process –kill, killall, pkill, xkill 27. rm command examplesGet confirmation before removing the file.$ rm -i filename.txtIt is very useful while giving shell metacharacters in the file name argument.Print the filename and get confirmation before removing the file.$ rm -i file*Following example recursively removes all files and directories under the example directory. This also removes the example directory itself.$ rm -r example28. cp command examplesCopy file1 to file2 preserving the mode, ownership and timestamp.$ cp -p file1 file2Copy file1 to file2. if file2 exists prompt for confirmation before overwritting it.$ cp -i file1 file229. mv command examplesRename file1 to file2. if file2 exists prompt for confirmation before overwritting it.$ mv -i file1 file2Note: mv -f is just the opposite, which will overwrite file2 without prompting.mv -v will print what is happening during file rename, which is useful while specifying shell metacharacters in the file name argument.$ mv -v file1 file230. cat command examplesYou can view multiple files at the same time. Following example prints the content of file1 followed by file2 to stdout.$ cat file1 file2While displaying the file, following cat -n command will prepend the line number to each line of the output.$ cat -n /etc/logrotate.conf1 /var/log/btmp {2 missingok3 monthly4 create 0660 root utmp5 rotate 16 }31. mount command examplesTo mount a file system, you should first create a directory and mount it as shown below.# mkdir /u01# mount /dev/sdb1 /u01You can also add this to the fstab for automatic mounting. i.e Anytime system is restarted, the filesystem will be mounted./dev/sdb1 /u01 ext2 defaults 0 232. chmod command exampleschmod command is used to change the permissions for a file or directory.Give full access to user and group (i.e read, write and execute ) on a specific file.$ chmod ug+rwx file.txtRevoke all access for the group (i.e read, write and execute ) on a specific file.$ chmod g-rwx file.txtApply the file permissions recursively to all the files in thesub-directories.$ chmod -R ug+rwx file.txtMore chmod examples: 7 Chmod Command Examples for Beginners33. chown command exampleschown command is used to change the owner and group of a file. \To change owner to oracle and group to db on a file. i.e Change both owner and group at the same time.$ chown oracle:dba dbora.shUse -R to change the ownership recursively.$ chown -R oracle:dba /home/oracle34. passwd command examplesChange your password from command line using passwd. This will prompt for the old password followed by the new password.$ passwdSuper user can use passwd command to reset others password. This will not prompt for current password of the user.# passwd USERNAMERemove password for a specific user. Root user can disable password for a specific user. Once the password is disabled, the user can login without entering the password.# passwd -d USERNAME35. mkdir command examplesFollowing example creates a directory called temp under your home directory.$ mkdir ~/tempCreate nested directories using one mkdir command. If any of these directories exist already, it will not display any error. If any of these directories doesn’t exist, it will create them.$ mkdir -p dir1/dir2/dir3/dir4/36. ifconfig command examplesUse ifconfig command to view or configure a network interface on the Linux system.View all the interfaces along with status.$ ifconfig -aStart or stop a specific interface using up and down command as shown below.$ ifconfig eth0 up$ ifconfig eth0 downMore ifconfig examples: Ifconfig: 7 Examples To Configure Network Interface37. uname command examplesUname command displays important information about the system such as —Kernel name, Host name, Kernel release number,Processor type, etc.,Sample uname output from a Ubuntu laptop is shown below.$ uname -aLinux john-laptop 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19 01:12:52 UTC 2010 i686 GNU/Linux38. whereis command examplesWhen you want to find out where a specific Unix command exists (for example, where does ls command exists?), you can execute the following command.$ whereis lsls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gzWhen you want to search an executable from a path other than the whereis default path, you can use -B option and give path as argument to it. This searches for the executable lsmk in the /tmp directory, and displays it, if it is available.$ whereis -u -B /tmp -f lsmklsmk: /tmp/lsmk39. whatis command examplesWhatis command displays a single line description about a command.$ whatis lsls (1) - list directory contents$ whatis ifconfigifconfig (8) - configure a network interface40. locate command examplesUsing locate command you can quickly search for the location of a specific file (or group of files). Locate command uses the database created by updatedb.The example below shows all files in the system that contains the word crontab in it.$ locate crontab/etc/anacrontab/etc/crontab/usr/bin/crontab/usr/share/doc/cron/examples/crontab2english.pl.gz/usr/share/man/man1/crontab.1.gz/usr/share/man/man5/anacrontab.5.gz/usr/share/man/man5/crontab.5.gz/usr/share/vim/vim72/syntax/crontab.vim41. man command examplesDisplay the man page of a specific command.$ man crontabWhen a man page for a command is located under more than one section, you can view the man page for that command from a specific section as shown below.$ man SECTION-NUMBER commandnameFollowing 8 sections are available in the man page.1.General commands2.System calls3. C library functions4.Special files (usually devices, those found in /dev) and drivers5.File formats and conventions6.Games and screensavers7.Miscellaneous8.System administration commands and daemonsFor example, when you do whatis crontab, you’ll notice that crontab has two man pages (section 1 and section 5). To view section 5 of crontab man page, do the following.$ whatis crontabcrontab (1) - maintain crontab files for individual users (V3) crontab (5) - tables for driving cron$ man 5 crontab42. tail command examplesPrint the last 10 lines of a file by default.$ tail filename.txtPrint N number of lines from the file named filename.txt$ tail -n N filename.txtView the content of the file in real time using tail -f. This is useful to view the log files, that keeps growing. The command can be terminated using CTRL-C.$ tail -f log-fileMore tail examples: 3 Methods To View tail -f output of Multiple Log Files in One Terminal43. less command examplesless is very efficient while viewing huge log files, as it doesn’t need to load the full file while opening.$ less huge-log-file.logOne you open a file using less command, following two keys are very helpful.CTRL+F – forward one windowCTRL+B – backward one windowMore less examples: Unix Less Command: 10 Tips for Effective Navigation 44. su command examplesSwitch to a different user account using su command. Super user can switch to any other user without entering their password.$ su - USERNAMEExecute a single command from a different account name. In the following example, john can execute the ls command as raj username. Once the command is executed, it will come back to john’s account.[john@dev-server]$ su - raj -c 'ls'[john@dev-server]$Login to a specified user account, and execute the specified shell instead of the default shell.$ su -s 'SHELLNAME' USERNAME45. mysql command examplesmysql is probably the most widely used open source database on Linux. Even if you don’t run a mysql database on your server, you might end-up using the mysql command ( client ) to connect to a mysql database running on the remote server.To connect to a remote mysql database. This will prompt for a password.$ mysql -u root -p -h 192.168.1.2To connect to a local mysql database.$ mysql -u root -pIf you want to specify the mysql root password in the command line itself, enter it immediately after -p (without any space).46. yum command examplesTo install apache using yum.$ yum install httpdTo upgrade apache using yum.$ yum update httpdTo uninstall/remove apache using yum.$ yum remove httpd47. rpm command examplesTo install apache using rpm.# rpm -ivh httpd-2.2.3-22.0.1.el5.i386.rpmTo upgrade apache using rpm.# rpm -uvh httpd-2.2.3-22.0.1.el5.i386.rpmTo uninstall/remove apache using rpm.# rpm -ev httpdMore rpm examples: RPM Command: 15 Examples to Install, Uninstall, Upgrade, Query RPM Packages48. ping command examplesPing a remote host by sending only 5 packets.$ ping -c 5 More ping examples: Ping Tutorial: 15 Effective Ping Command Examples49. date command examplesSet the system date:# date -s "01/31/2010 23:59:53"Once you’ve c hanged the system date, you should syncronize the hardware clock with the system date as shown below.# hwclock –systohc# hwclock --systohc –utc50. wget command examplesThe quick and effective method to download software, music, video from internet is using wget command.$ wget/sourceforge/nagios/nagios-3.2.1.ta r.gzDownload and store it with a different name.$ wget -O taglist.zip/scripts/download_script.php?src_id。