Saturday, September 24, 2022

Five lesser known amazing linux commands



In this post we are going to discuss about some Linux commands which are not so famous but are actually very useful, i will be using following file to explain these commands with examples if needed :

appuser1@ubuntu:~$ cat Linux_Distributions.txt
kali linux - Amazing For security and Penetration Testing
Alpine Linux - Good lightweight Linux distribution
Void Linux - Good lightweight Linux distribution
Absolute Linux - Good lightweight Linux distribution
Puppy Linux - Good lightweight Linux distribution
appuser1@ubuntu:~$

Well if you have noticed our  test file have name of some of the good Linux distributions 
if you want to know more about Linux distributions 

if you want to learn about Other Popular Linux distributions , you can read here 


you can practice these commands in your own Ubuntu Linux system, which you can create using USB, you read steps here

create bootable usb for ubuntu from windows

here is our list of commands :

1. "seq" command :
if you need to generate some sequence for script or any other purpose, this command is certainly a good tool for you, you can generate sequence from zero, or from a starting number or you can even start from zero.

appuser1@ubuntu:~$ seq 1 3
1
2
3
appuser1@ubuntu:~$ seq 1 5
1
2
3
4
5
appuser1@ubuntu:~$ seq 2
1
2
appuser1@ubuntu:~$ seq 5 7
5
6
7
appuser1@ubuntu:~$ seq -2 2
-2
-1
0
1
2
appuser1@ubuntu:~$


2. "nl" command :
if you want to print line numbers in front of output from a file or standard output, this command come handy, what is more interesting feature of this command is that by default it will print line number only in front lines having some content and not empty lines.


appuser1@ubuntu:~$ nl Linux_Distributions.txt
1 kali linux - Amazing For security and Penetration Testing

2 Alpine Linux - Good lightweight Linux distribution
3 Void Linux - Good lightweight Linux distribution
4 Absolute Linux - Good lightweight Linux distribution
5 Puppy Linux - Good lightweight Linux distribution
appuser1@ubuntu:~$


3. "tac" command :
We all use cat command, however very few people know about its sibling tac command ( yes that is cat written in reverse), like cat it will print content of file but in backward direction meaning it will start from last line first,
if you want to learn cat command, you can read this here :
 
Basic Linux commands in 1 hour 

this tutorial will help you to understand basic Linux commands / Unix commands in just one hours


appuser1@ubuntu:~$ tac Linux_Distributions.txt
Puppy Linux - Good lightweight Linux distribution
Absolute Linux - Good lightweight Linux distribution
Void Linux - Good lightweight Linux distribution
Alpine Linux - Good lightweight Linux distribution
kali linux - Amazing For security and Penetration Testing
appuser1@ubuntu:~$


4. "rev" command :
Some times you may have thought How do I reverse the contents of a file in Linux? Or How do I reverse a string in bash? As name suggests rev command will print content of a file in reverse direction, in other words characters will be printed in reverse direction, 


appuser1@ubuntu:~$ rev Linux_Distributions.txt
gnitseT noitarteneP dna ytiruces roF gnizamA - xunil ilak
noitubirtsid xuniL thgiewthgil dooG - xuniL eniplA
noitubirtsid xuniL thgiewthgil dooG - xuniL dioV
noitubirtsid xuniL thgiewthgil dooG - xuniL etulosbA
noitubirtsid xuniL thgiewthgil dooG - xuniL yppuP
appuser1@ubuntu:~$



5. "script" command :
Sometime you need to log everything going on terminal, there may be several reasons for this, for example you are doing some troubleshooting and you are too busy to note down the results, script command is available for your rescue in such situation, just use script and everything will logged in a file called type typescript, and do you know how to stop script command in Linux, just like starting , stopping it is also super simple, just type exit :


appuser1@ubuntu:~$ script
Script started, file is typescript
$ ls -tlr Linux_Distributions.txt
-rw-r--r-- 1 appuser1 app 263 Sep 21 12:10 Linux_Distributions.txt
$ exit
Script done, file is typescript
appuser1@ubuntu:~$ ls -tlr typescript
-rw-r--r-- 1 appuser1 app 294 Sep 21 12:20 typescript
appuser1@ubuntu:~$ cat typescript
Script started on 2022-09-21 12:20:12-07:00 [TERM="xterm" TTY="/dev/pts/0"
COLUMNS="168" LINES="44"]
$ ls -tlr Linux_Distributions.txt
-rw-r--r-- 1 appuser1 app 263 Sep 21 12:10 Linux_Distributions.txt
$ exit
Script done on 2022-09-21 12:20:30-07:00 [COMMAND_EXIT_CODE="0"]
appuser1@ubuntu:~$



if you want learn Unix/Linux Commands in detail, here is the link

Learn Unix/Linux Commands in detail

Get latest Tech world updates

Go to home page

No comments:

Post a Comment