top of page
  • Writer's pictureMukesh Chanderia

Linux - Commands Part 3

Updated: Aug 21, 2021

Semicolon is used to run multiple command in single line


[root@localhost ~]# touch file1 ; mkdir Dir1


Keyword "tac" is used to read reverse.


Note : Cat /Tac


root@localhost ~]# cat -n mukesh.txt

1 Hello Ji

2 Tuse Great Ho

3 You Can

4 You Will

5 Great


[root@localhost ~]# tac mukesh.txt

Great

You Will

You Can

Tuse Great Ho

Hello Ji


Now to put sequence number with cat "-n" but with tac we need to use "nl" command


[root@localhost ~]# nl mukeshji.txt

1 this is India Web Server

2 this is US Web Server


nl stands for number of lines in a file


root@localhost ~]# tac mukesh.txt | nl

1 Great

2 You Will

3 You Can

4 Tuse Great Ho

5 Hello Ji


To find out top three and bottom 3 command


Use Head and Tail Commands


root@localhost ~]# head -n 3 /etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin


[root@localhost ~]# tail -n 3 /etc/passwd

postfix:x:89:89::/var/spool/postfix:/sbin/nologin

tcpdump:x:72:72::/:/sbin/nologin

mukesh:x:1000:1000:Mukesh:/home/mukesh:/bin/bash


Tail command is used to read logs

tail -F /var/log/message



ECHO : It is used to print file.


root@localhost ~]# echo "Alpha Beta Gamma"

Alpha Beta Gamma


To add output to existing file use ">"


[root@localhost ~]# echo "this is India Web Server" > mukesh.txt


To Append use ">>"

root@localhost ~]# echo "this is US Web Server" >> mukesh.txt


Echo can also be used to create empty file

echo > mukesh.txt



15 views0 comments

Recent Posts

See All

Comments


bottom of page