3 Ways to Permanently and Securely Delete ‘Files and Directories’ in Linux

In most cases the means we use to delete a file from our computers such as using Delete key, Trash files or rm command, which do not permanently and securely remove the file from the hard disk (or any storage media).

The file is simply hidden from users and it resides somewhere on the hard disk. It can be recovered by data thieves, law enforcement or other threats.

Suggested Read: 3 Ways to Delete All Files in a Directory Except One or Few Files

Assuming a file contains classified or secret content such as usernames and passwords of a security system, an attacker with the necessary knowledge and skills can easily recover a deleted copy of the file and access these user credentials (and you can probably guess the aftermath of such as scenario).

In this article, we will explain a number of command line tools for permanently and securely deleting files in Linux.

1. Shred – Overwrite a File to Hide Content

shred overwrites a file to hide its contents, and can optionally delete it as well.

$ shred -zvu -n  5 passwords.list

In the command below, the options:

  1. -z – adds a final overwrite with zeros to hide shredding
  2. -v – enables display of operation progress
  3. -u – truncates and removes file after overwriting
  4. -n – specifies number of times to overwrite file content (the default is 3)
shred - overwrite a file to hide its contents

shred – overwrite a file to hide its contents

You can find more usage options and information in the shred man page:

$ man shred

2. Wipe – Securely Erase Files in Linux

A Linux wipe command securely erases files from magnetic memory and thereby making it impossible to recover deleted files or directory content.

First, you need to install wipe tool in order to it, run the appropriate command below:

$ sudo apt-get install wipe   [On Debian and its derivatives]
$ sudo yum install wipe       [On RedHat based systems]

The following command will destroy everything under the directory private.

$ wipe -rfi private/*

where the flags used:

  1. -r – tells wipe to recurse into subdirectories
  2. -f – enables forced deletion and disable confirmation query
  3. -i – shows progress of deletion process
Wipe - Securely Erase Files in Linux

Wipe – Securely Erase Files in Linux

Note: Wipe only works reliably on magnetic memory, therefore use the other methods for solid state disks (memory).

Read through the wipe man page for additional usage options and instructions:

$ man wipe

3. Secure-deletetion Toolkit for Linux

Secure-delete is a collection of secure file deletion tools, that contains srm (secure_deletion) tool, which is used to remove files securely.

First you need to install it using the relevant command below:

$ sudo apt-get install secure-delete   [On Debian and its derivatives]
$ sudo yum install secure-delete       [On RedHat based systems]

Once installed, you can use srm tool to remove files or directories securely on a Linux system as follows.

$ srm -vz private/*

where the options used:

  1. -v – enables verbose mode
  2. -z – wipes the last write with zeros instead of random data
srm - Securely Delete Files in Linux

srm – Securely Delete Files in Linux

Read through the srm man page for more usage options and information:

$ man srm

4. sfill -Secure Free Disk/Inode Space Wiper

sfill is a part of secure-deletetion toolkit, is a secure free disk and inode space wiper, it deletes files on free disk space in a secure method. sfill checks the the free space on the specified partition and fills it with random data from /dev/urandom.

The command below will execute sfill on my root partition, with the -v switch enabling verbose mode:

$ sudo sfill -v /home/aaronkilik/tmp/

Assuming you created a separate partition, /home to store normal system users home directories, you can specify a directory on that partition to apply sfill on it:

$ sudo sfill -v /home/username

The are a few limitations of sfill that you can read about in the man page, where you can also find additional usage flags and instructions:

$ man sfill

Note: These following two tools (sswap and sdmem) in the secure-deletetion toolkit are not directly relevant for the scope of this guide, however, we will explain them for knowledge purpose and future use.

5. sswap – Secure Swap Wiper

It is a secure partition wiper, sswap deletes data present on your swap partition in a secure manner.

Caution: remember to unmount your swap partition before using sswap! Otherwise your system might crash!

Simply determine you swap partition (and check if paging and swapping devices/files are turned on using swapon command), next, disable paging and swapping devices/files with swapoff command (renders swap partition unusable).

Then run sswap command on the swap partition:

$ cat /proc/swaps 
$ swapon
$ sudo swapoff /dev/sda6
$ sudo sswap /dev/sda6    #this command may take some time to complete with 38 default passes
sswap - Secure Swap Wiper

sswap – Secure Swap Wiper

Make an effort to read through the sswap man page for more usage options and information:

$ man sswap

6. sdmem – Secure Memory Wiper

sdmem is a secure memory wiper, it is designed to remove data present in your memory (RAM) in a secure manner.

It was originally named smem, but because on Debain systems there exists another package called smem – report memory consumption on per-process and per-user basis, the developer decided to rename it sdmem.

$ sudo sdmem -f -v

For more usage information, read through the sdmem man page:

$ man sdmem 

Suggested Read: PhotoRec – Recover Deleted or Lost Files in Linux

That’s it! In this article, we reviewed a number command line tools for permanently as well as securely deleting files in Linux.

 

11 Lesser Known Useful Linux Commands

Linux command line attracts most of the Linux Enthusiastic. A normal Linux user generally posses a vocabulary of roughly 50-60 commands to carry out their day-to-day task. Linux commands and their switches remains the most valuable treasure for a Linux-userShell-script programmer and Administrator. There are some Linux Commands which are lesser Known, yet very useful and handy irrespective of the fact whether you are a Novice or an Advanced User.

Lesser Known Linux Commands

Lesser Known Linux Commands

This very article aims at throwing light on some of the lesser known Linux commands which surely will help you to handle your Desktop/Server more efficiently.

1. sudo !! command

Running the command without specifying sudo command will give you permission denied error. So, you don’t need to rewrite the whole command again just put ‘!!‘ will grab the last command.

$ apt-get update

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) 
E: Unable to lock directory /var/lib/apt/lists/ 
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) 
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ sudo !!

sudo apt-get update 
[sudo] password for server: 
…
..
Fetched 474 kB in 16s (28.0 kB/s) 
Reading package lists... Done 
server@localhost:~$

2. python command

The below command generates a simple web page over HTTP for the directory structure tree and can be accessed at port 8000 in browser till interrupt signal is sent.

# python -m SimpleHTTPServer

python -m SimpleHTTPServer

Directory Structure Tree

3. mtr Command

Most of us are familiar with ping and traceroute. How about combining the functionality of both the command into one with mtr command. In case mtr is not installed into your machine, apt or yum the required package.

$ sudo apt-get install mtr (On Debian based Systems)
# yum install mtr (On Red Hat based Systems)

Now run mtr command to start investigating the network connection between the host mtr runs on and google.com.

# mtr google.com

mtr command

mtr command

4. Ctrl+x+e Command

This command is very much useful for administrator and developers. To Automate day-to-day task an administrator needs to open editor by typing vivimnano, etc. How about firing instant editor (from terminal).

Just Press “Ctrl-x-e” from the terminal prompt and start working in editor.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

5. nl Command

The “nl command” number the lines of a file. Number the lines of a file say ‘one.txt‘ with lines say (FedoraDebianArchSlack and Suse). First list the content of a file “one.txt” using cat command.

# cat one.txt 

fedora 
debian 
arch 
slack 
suse

Now run “nl command” to list them in a numbered fashion.

# nl one.txt 

1 fedora 
2 debian 
3 arch 
4 slack 
5 suse

6. shuf Command

The “shuf” command randomly select lines/files/folder from a file/folder. First list the contents of a folder using ls command.

# ls 

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
#  ls | shuf (shuffle Input)

Music 
Documents 
Templates 
Pictures 
Public 
Desktop 
Downloads 
Videos
#  ls | shuf -n1 (pick on random selection)

Public
# ls | shuf -n1 

Videos
# ls | shuf -n1 

Templates
# ls | shuf -n1 

Downloads

Note: You can always replace ‘n1‘ with ‘n2‘ to pick two random selection or any other number of random selection using n3n4.

7. ss Command

The “ss” stands for socket statistics. The command investigates the socket and shows information similar to netstat command. It can display more TCP and state informations than other tools.

# ss 

State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port   
ESTAB      0      0           192.168.1.198:41250        *.*.*.*:http    
CLOSE-WAIT 1      0               127.0.0.1:8000             127.0.0.1:41393   
ESTAB      0      0           192.168.1.198:36239        *.*.*.*:http    
ESTAB      310    0               127.0.0.1:8000             127.0.0.1:41384   
ESTAB      0      0           192.168.1.198:41002       *.*.*.*:http    
ESTAB      0      0               127.0.0.1:41384            127.0.0.1:8000

8. last Command

The “last” command show the history of last logged in users. This command searches through the file “/var/log/wtmp” and shows a list of logged-in and logged-out users along with tty’s.

#  last 
server   pts/0        :0               Tue Oct 22 12:03   still logged in   
server   tty8         :0               Tue Oct 22 12:02   still logged in   
…
...
(unknown tty8         :0               Tue Oct 22 12:02 - 12:02  (00:00)    
server   pts/0        :0               Tue Oct 22 10:33 - 12:02  (01:29)    
server   tty7         :0               Tue Oct 22 10:05 - 12:02  (01:56)    
(unknown tty7         :0               Tue Oct 22 10:04 - 10:05  (00:00)    
reboot   system boot  3.2.0-4-686-pae  Tue Oct 22 10:04 - 12:44  (02:39)    

wtmp begins Fri Oct  4 14:43:17 2007

9. curl ifconfig.me

So how do you obtain your External IP address? Using google?. Well the command output your external IP address right into your terminal.

# curl ifconfig.me

Note: You might don’t have curl package installed, you have to apt/yum to install package.

10. tree command

Get the current directory structure in tree like format.

# tree
. 
|-- Desktop 
|-- Documents 
|   `-- 37.odt 
|-- Downloads 
|   |-- attachments.zip 

|   |-- ttf-indic-fonts_0.5.11_all.deb 
|   |-- ttf-indic-fonts_1.1_all.deb 
|   `-- wheezy-nv-install.sh 
|-- Music 
|-- Pictures 
|   |-- Screenshot from 2013-10-22 12:03:49.png 
|   `-- Screenshot from 2013-10-22 12:12:38.png 
|-- Public 
|-- Templates 
`-- Videos 

10 directories, 23 files

11. pstree

This commands shows all the processes running currently along with associated child process, in a tree like format similar to ‘tree‘ command output.

# pstree 
init─┬─NetworkManager───{NetworkManager} 
     ├─accounts-daemon───{accounts-daemon} 
     ├─acpi_fakekeyd 
     ├─acpid 
     ├─apache2───10*[apache2] 
     ├─at-spi-bus-laun───2*[{at-spi-bus-laun}] 
     ├─atd 
     ├─avahi-daemon───avahi-daemon 
     ├─bluetoothd 
     ├─colord───{colord} 
     ├─colord-sane───2*[{colord-sane}] 
     ├─console-kit-dae───64*[{console-kit-dae}] 
     ├─cron 
     ├─cupsd 
     ├─2*[dbus-daemon] 
     ├─dbus-launch 
     ├─dconf-service───2*[{dconf-service}] 
     ├─dovecot─┬─anvil 
     │         ├─config 
     │         └─log 
     ├─exim4 
     ├─gconfd-2 
     ├─gdm3─┬─gdm-simple-slav─┬─Xorg 
     │      │                 ├─gdm-session-wor─┬─x-session-manag─┬─evolution-a+ 
     │      │                 │                 │                 ├─gdu-notific+ 
     │      │                 │                 │                 ├─gnome-scree+ 
     │      │                 │                 │                 ├─gnome-setti+ 
     │      │                 │                 │                 ├─gnome-shell+++ 
     │      │                 │                 │                 ├─nm-applet──+++ 
     │      │                 │                 │                 ├─ssh-agent 
     │      │                 │                 │                 ├─tracker-min+ 
     │      │                 │                 │                 ├─tracker-sto+ 
     │      │                 │                 │                 └─3*[{x-sessi+ 
     │      │                 │                 └─2*[{gdm-session-wor}] 
     │      │                 └─{gdm-simple-slav} 
     │      └─{gdm3} 
     ├─6*[getty] 
     ├─gnome-keyring-d───9*[{gnome-keyring-d}] 
     ├─gnome-shell-cal───2*[{gnome-shell-cal}] 
     ├─goa-daemon───{goa-daemon} 
     ├─gsd-printer───{gsd-printer} 
     ├─gvfs-afc-volume───{gvfs-afc-volume}

That’s all for now. In the next article of mine I would cover certain other lesser known Linux commands which would be fun. Till then stay tuned and connected to Tecmint. Like and share us and help us get spread.

Read Also:

  1. 10 Lesser Known Linux Commands – Part 2
  2. 10 Lesser Known Commands for Linux – Part 3
  3. 10 Lesser Known Effective Linux Commands – Part IV
  4. 10 Lesser Known Useful Linux Commands- Part V

10 Lesser Known Linux Commands – Part 2

Continuing the last conversation from 11 Lesser Known Useful Linux Commands – Part I here in this article we will be focusing on other lesser known Linux commands, that will prove to be very much useful in managing Desktop and Server.

Lesser Known Linux Commands

10 Lesser Known Linux Commands

12. <space> Command

Every piece of command you type in terminal gets recorded in the history and can be retried using historycommand.

How about cheating history command? Yeah you can do it and its very easy. Just put one or more white space before typing a command in terminal and your command wont be recorded.

Lets give it a try, we will try five common Linux commands (say lspwdunameecho “hi” and who) in terminal after one white space and check if these commands are docked in history or not.

avi@localhost:~$  ls
avi@localhost:~$  pwd
avi@localhost:~$  uname
avi@localhost:~$  echo “hi”
avi@localhost:~$  who

Now run ‘history‘ command to see whether these above executed commands are recorded or not.

avi@localhost:~$ history

   40  cd /dev/ 
   41  ls 
   42  dd if=/dev/cdrom1 of=/home/avi/Desktop/squeeze.iso 
   43  ping www.google.com 
   44  su

You see our last executed commands are not logged. we can also cheat history by using an alternate command ‘cat | bash‘ of-course without quotes, in the same way as above.

13. stat Command

The stat command in Linux displays the status information of a file or filesystem. The stat shows a whole lot of information about the file which name is passed as argument. Status Information includes file SizeBlocksAccess PermissionDate-time of file last access, Modifychange, etc.

avi@localhost:~$ stat 34.odt 

  File: `34.odt' 
  Size: 28822     	Blocks: 64         IO Block: 4096   regular file 
Device: 801h/2049d	Inode: 5030293     Links: 1 
Access: (0644/-rw-r--r--)  Uid: ( 1000/     avi)   Gid: ( 1000/     avi) 
Access: 2013-10-14 00:17:40.000000000 +0530 
Modify: 2013-10-01 15:20:17.000000000 +0530 
Change: 2013-10-01 15:20:17.000000000 +0530

14. <alt>. and <esc>.

The above key combination is not actually a command but a tweak which put the last command argument at prompt, in the order of last entered command to previous entered command. Just press and hold ‘Alt‘ or ‘Esc‘ and continue pressing ‘.‘.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

15. pv command

You might have seen simulating text in Movies specially Hollywood Movies, where the text appears as if it is being typed in the Real time. You can echo any kind of text and output in simulating fashion using ‘pv‘ command, as pipelined above. The pv command might not be installed in your system, and you have to apt or yum the required packages to install ‘pv‘ into your box.

root@localhost:# echo "Tecmint [dot] com is the world's best website for qualitative Linux article" | pv -qL 20
Sample Outpit
Tecmint [dot] com is the world's best website for qualitative Linux article

16. mount | column -t

The above command shows the list of all the mounted filesystem in a nice formatting with specification.

avi@localhost:~$ mount | column -t
Sample Outpit
/dev/sda1    on  /                         type  ext3         (rw,errors=remount-ro) 
tmpfs        on  /lib/init/rw              type  tmpfs        (rw,nosuid,mode=0755) 
proc         on  /proc                     type  proc         (rw,noexec,nosuid,nodev) 
sysfs        on  /sys                      type  sysfs        (rw,noexec,nosuid,nodev) 
udev         on  /dev                      type  tmpfs        (rw,mode=0755) 
tmpfs        on  /dev/shm                  type  tmpfs        (rw,nosuid,nodev) 
devpts       on  /dev/pts                  type  devpts       (rw,noexec,nosuid,gid=5,mode=620) 
fusectl      on  /sys/fs/fuse/connections  type  fusectl      (rw) 
binfmt_misc  on  /proc/sys/fs/binfmt_misc  type  binfmt_misc  (rw,noexec,nosuid,nodev) 
nfsd         on  /proc/fs/nfsd             type  nfsd         (rw)

17. Ctr+l command

Before going further, let me ask you how you clear your terminal. Hmmm! You type “clear” at prompt. Well the above command perform the action of cleaning your terminal all at a once. Just press “Ctr+l” and see how it clears your terminal all at once.

18. curl command

How about checking your unread mail from the command line. This command is very useful for those who work on headless server. Again it asks for password at run time and you need not hard code your password in the above line, which is otherwise a security risk.

avi@localhost:~$ curl -u avishek1210@gmail.com --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/>/;'
Sample Outpit
Enter host password for user 'avishek1210@gmail.com': 
Gmail - Inbox for avishek1210@gmail.com 
People offering cars in Delhi - Oct 26 
	Quikr Alerts 
another dependency question 
	Chris Bannister 
	Ralf Mardorf 
	Reco 
	Brian 
	François Patte 
	Curt 
	Siard 
	berenger.morel 
Hi Avishek - Download your Free MBA Brochure Now... 
	Diya 
★Top Best Sellers Of The Week, Take Your Pick★ 
	Timesdeal 
aptitude misconfigure? 
	Glenn English 
Choosing Debian version or derivative to run Wine when resource poor 
	Chris Bannister 
	Zenaan Harkness 
	Curt 
	Tom H 
	Richard Owlett 
	Ralf Mardorf 
	Rob Owens

19. screen Command

The screen command makes it possible to detach a long running process from a session that can again be reattached, as and when required which provides flexibility in command execution.

To run a process (long) we generally execute as

avi@localhost:~$ ./long-unix-script.sh

Which lacks flexibility and needs the user to continue with the current session, however if we execute the above command as.

avi@localhost:~$ screen ./long-unix-script.sh

It can be de-attached or re-attached in different sessions. When a command is executing press “Ctrl + A” and then “d” to de-attach. To attach run.

avi@localhost:~$ screen -r 4980.pts-0.localhost

Note: Here, the later part of this command is screen id, which you can get using ‘screen -ls‘ command. To know more about ‘screen command‘ and their usage, please read our article that shows some useful 10 screen commands with examples.

20. file

No! the above command is not a typo. ‘file‘ is a command which gives you information about the type of file.

avi@localhost:~$ file 34.odt 

34.odt: OpenDocument Text

21. id

The above command print real and effective user and group ids.

avi@localhost:~$ id
Sample Output
uid=1000(avi) gid=1000(avi) 
groups=1000(avi),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth),117(scanner)

That’s all for now. Seeing the success of last article of this series and this very article, I’ll be coming with another part of this article containing several other Lesser Known Linux commands very soon. Till then Stay Tuned and connected to Tecmint. Don’t Forget to provide us with your value-able Feedback in Comments.

Read Also

  1. 10 Lesser Known Commands for Linux – Part 3
  2. 10 Lesser Known Effective Linux Commands – Part IV
  3. 10 Lesser Known Useful Linux Commands- Part V

10 Lesser Known Commands for Linux – Part 3

Overwhelmed with the response of last two articles of “Lesser Known Linux Article” series namely.

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part 2
  3. 10 Lesser Known Effective Linux Commands – Part IV
  4. 10 Lesser Known Useful Linux Commands- Part V

Lesser Known Linux Commands

10 Lesser Known Linux Commands

We have come up with the third article of this series which includes few other lesser known Linux commands, worth knowing. May be you are already aware of these commands, no doubt you are an experienced Linux user and loves exploration.

22. ^foo^bar Command

Run the last command with modification, in a single instance. Suppose I need to run a command ‘ls -l‘ to long list the content of a directory say ‘Desktop’. Accidentally, you type ‘lls -l‘. So now you will have to retype the whole command or edit the previous command using navigation key. That is painful when the command is long.

avi@localhost:~/Desktop$ lls -l 

bash: lls: command not found
avi@localhost:~/Desktop$ ^lls^ls 

ls -l 
total 7489440 

drwxr-xr-x 2 avi  avi       36864 Nov 13  2012 101MSDCF 
-rw-r--r-- 1 avi  avi      206833 Nov  5 15:27 1.jpg 
-rw-r--r-- 1 avi  avi      158951 Nov  5 15:27 2.jpg 
-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc

Note: In the above replacement we used “^typo(to be replaced)^original_command”. This command may be very dangerous if you knowingly or unknowingly replaced the typo with system command or anything risky say rm -rf.

23. > file.txt Command

This command flush the contents of a file without the need of removing and creating the same file again. This command is very useful in scripting language when we need an output or log on the same file again and again.

I have a file say ‘test.txt’ on my ‘Desktop‘ with a lot of text.

avi@localhost:~/Desktop$ cat test.txt 

Linux 
GNU 
Debian 
Fedora 
kali 
ubuntu 
git 
Linus 
Torvalds
avi@localhost:~/Desktop$ > test.txt 
avi@localhost:~/Desktop$ cat test.txt

Note: Again, this command can be dangerous, don’t ever try to flush the contents of a system file or configuration file. If you do so, you will be in serious trouble.

24. at Command

The ‘at‘ command is similar to cron command and can be used for scheduling a task or command to run at specified time.

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012

OR

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM
Sample Output
-rw-r--r-- 1 avi  avi      220492 Nov  1 13:49 Screenshot-1.png 
-rw-r--r-- 1 root root        358 Oct 17 10:11 sources.list 
-rw-r--r-- 1 avi  avi  4695982080 Oct 10 20:29 squeeze.iso 
..
..
-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc 
-rw-r--r-- 1 avi  avi       96206 Nov  5 12:56 Untitled 1.odt 
-rw-r--r-- 1 avi  avi        9405 Nov 12 23:22 Untitled.png

Note: echo “ls -l” : This string echo’s the command (here ls -l) on standard terminal. You can replace ‘ls -l‘ with any command of your need and choice.

> : redirects the output

The /dev/pts/0 : This is the output device and/or file, where output is sought, here the output is at terminal.

In my case, my tty is at /dev/pts/0, at that time. You can check your tty by running command tty.

avi@localhost:~/Desktop$ tty 

/dev/pts/0

Note: The ‘at‘ command execute the task as soon as the system clock matches the specified time.

25. du -h –max-depth=1 Command

The below command outputs the size of sub-folders within the current directory, in human readable format.

avi@localhost:/home/avi/Desktop# du -h --max-depth=1 

38M	./test 
1.1G	./shivji 
42M	./drupal 
6.9G	./101MSDCF 
16G	.

Note: The above command can be very much useful in checking system disk usage.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

26. expr Command

The ‘expr‘ command is not that much lesser known command. This command is very much useful in carrying out simple mathematical calculation in terminal.

avi@localhost:/home/avi/Desktop# expr 2 + 3 
5
avi@localhost:/home/avi/Desktop# expr 6 – 3 
3
avi@localhost:/home/avi/Desktop# expr 12 / 3 
4
avi@localhost:/home/avi/Desktop# expr 2 \* 9 
18

27. look Command

Check for words from English dictionary in case of confusion, from the terminal itself. Viz., I am a bit confused if the spelling is carrier or carieer.

avi@localhost:/home/avi/Documents# look car 

Cara 
Cara's 
…
... 
carps 
carpus 
carpus's 
carrel 
carrel's 
carrels 
carriage 
carriage's 
carriages 
carriageway 
carriageway's 
carried 
carrier 
carrier's 
carriers 
carries 
…
... 
caryatids

The above command showed all the words from dictionary starting with string ‘car’. I got what I was searching for.

28. yes Command

Another command which is not used frequently on regular basis, normally but is very useful in scripting language and for system Administrators.

This command continues to print a given string, till interrupt instruction is given by you.

avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to" 

Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
…
…
...
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to

29. factor Command

The factor command is actually a command of mathematical origin. This command outputs all the factors of a given number.

avi@localhost:~/Desktop$ factor 22 
22: 2 11
avi@localhost:~/Desktop$ factor 21 
21: 3 7
avi@localhost:~/Desktop$ factor 11 
11: 11

30. ping -i 60 -a IP_address

All of us use ping command to check is server is live or not. And I usually ping google, to check if I am connected to internet or not.

It is sometimes irritating, when you wait and keep watching your terminal to get reply of ping command or say, wait for server to get connected.

How about an audible sound as soon as the server comes live.

avi@localhost:~/Desktop$ ping -i 60 -a www.google.com 

PING www.google.com (74.125.200.103) 56(84) bytes of data. 
64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms 
64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms

Let me tell you one thing, before you report that the command didn’t return any audible sound. Make sure your system audio is not mute, sound theme must be enabled in ‘sound preferences‘ and make sure ‘Enable window and window sound‘ is checked.

31. tac Command

This command is very interesting which prints the content of a text file in reverse order, i.e., from last line to first line.

I have a text file 35.txt in my Documents directory, under home folder. Checking it’s content using cat command.

avi@localhost:~/Documents$ cat 35.txt
Sample Output
1. Linux is built with certain powerful tools, which are unavailable in windows. 

2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart. 

3.Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.

Now reverse the content of file using tac command.

avi@localhost:~/Documents$ tac 35.txt
Sample Output
3.Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages. 

2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart. 

1. Linux is built with certain powerful tools, which are unavailable in windows.

That’s all for now. If you are aware of other lesser known Linux commands, you can put a comment, so that we can include those in our future articles.

10 Lesser Known Effective Linux Commands – Part IV

Continuing the Lesser Known series, this fourth article of the series will let you know some useful funny and animated commands. Here we go into the practical session, without much theory.

10 Lesser Known Effective Commands

10 Lesser Known Effective Commands

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part 2
  3. 10 Lesser Known Commands for Linux – Part 3
  4. 10 Lesser Known Useful Linux Commands- Part V

In the fourth article of this series which includes few other lesser known Linux commands, worth knowing. Might be you’re already aware of these commands, no doubt you’re an experienced Linux user and loves exploration.

32. strace Command

The strace is a debugging tool which is used primarily for troubleshooting purpose in Linux. It might not be installed by default in your system and you may need to apt or yum the required package.

Trace a command execution using strace command:

root@tecmint [~]# strace pwd
Sample Output
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "7ELF
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
>
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
05I;
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0 mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000 mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0 mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000 mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000 ....

The strace command accepts a lot of arguments and have many options. Refer to man page for detailed information.

33. disown -a && exit Command

Most of the system administrators use screen command to control jobs running in the terminal background. Let’s say if you having a long running job and want to detach from the terminal, you use screen command to do it. But what if you don’t know how to use screen, here comes disown command to rescue.

The disown command is used to run the jobs continuously in the background even after you closing the terminal session. The syntax of the disown command is:

root@tecmint [~]# Command; disown -a && exit

To detach again the long running job in the terminal, use the jobs command to find the job number and then use disown %n where n is the job number. To verify actually the job is running use ps or top command. The nohupcommand is an alternative to the disown command.

34. getconf LONG_BIT Command

The above command shows your machine architecture if it is 32 bit or 64 bit?

root@tecmint [~]# getconf LONG_BIT

32

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

35. Display Date on the Terminal

The below command is a combination of several commands, better say it a script. For a person working at shell or terminal, without GUI seeing current system date is tedious job. You have to type ‘date‘ command to check today’s date.

Just execute the below command on you prompt and see the date and time on the above right corner of terminal.

root@tecmint [~]# while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &

Show Date in Terminal

Show Date in Terminal

36. convert Command

While writing tutorial, I usually need to produce output, many a times in image format. The above command combination does this for me. Say I need the output of tree command (for /etc/x11 directory) in image format. What I did at terminal was:

root@tecmint:/etc/X11# tree | convert label:@- /home/avi/tree.png

The output of the above command can be seen at the specified location (here, home directory of mine) with the file name specified as tree.png.

37. watch -t -n1 “date +%T|figlet”

Remember our description of “figlet” command in our earlier article “20 Funny Commands of Linux”. This command was very cool, this time we will be pipelining ‘figlet‘ to show animated digital clock in the terminal.

Just check-out yourself, remember you must have figlet installed on the system, do apt or yum to install the required package.

root@tecmint [~]# watch -t -n1 "date +%T|figlet"
Sample Output
 _  ___    ____   ___    _____ _  _                                                                                             Fri Nov 29 10:29:34 GMT 
/ |/ _ \ _|___ \ / _ \ _|___ /| || |
| | | | (_) __) | (_) (_) |_ \| || |_
| | |_| |_ / __/ \__, |_ ___) |__   _|
|_|\___/(_)_____|  /_/(_)____/   |_|

38. host and dig Commands

Although “host” and “dig” command is not that much lesser known, still not very frequently used. The host command is DNS lookup utility.

root@tecmint [~]# host www.google.com

www.google.com has address 173.194.66.147
www.google.com has address 173.194.66.105
www.google.com has address 173.194.66.99
www.google.com has address 173.194.66.104
www.google.com has address 173.194.66.106
www.google.com has address 173.194.66.103
www.google.com has IPv6 address 2a00:1450:400c:c03::68
root@tecmint [~]# dig www.google.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<

39. dstat Command

The dstat is a versatile tool, that generates statistics relating to system resource. By default your system might not have ‘dstat‘ installed. Do a apt or yum to install ‘dstat‘ before using this very colorful and description system resource generator.

root@tecmint [~]# dstat

dstat command

dstat command

40. bind -p Command

The ‘bind -p‘ command will show all the shortcuts available for BASH shell.

root@tecmint [~]# bind -p
Sample Output
"\C-g": abort 
"\C-x\C-g": abort 
"\e\C-g": abort 
"\C-j": accept-line
"\C-m": accept-line 
# alias-expand-line (not bound) 
# arrow-key-prefix (not bound) 
# backward-byte (not bound) 
"\C-b": backward-char 
"\eOD": backward-char 
"\e[D": backward-char 
"\e!": complete-command 
"\e/": complete-filename 
"\e@": complete-hostname 
"\e{": complete-into-braces 
"\e~": complete-username 
"\e$": complete-variable 
# copy-backward-word (not bound)
# copy-forward-word (not bound) 
# copy-region-as-kill (not bound)
....
....

41. touch /forcefsck

The above command will create an empty folder ‘forcefsck‘, under root directory. This will force Linux System to check the file system on the very next boot.

root@tecmint [~]# touch /forcefsck

That’s all for Now. You People are loving these ‘Lesser Known Commands‘ and hence we are continuing the series, the next article of this series will be available very soon.

Till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in our comment section. Do a favor to us, Like and share us and help us spread.

10 Lesser Known Useful Linux Commands- Part V

After four highly appreciated and such a successful series of Articles on “Lesser Known Linux Commands” we are here presenting you the last article on this series, obviously not the least. The previous articles are:

Lesser Known Linux Commands

Lesser Known Linux Commands

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part II
  3. 10 Lesser Known Commands for Linux – Part III
  4. 10 Lesser Known Effective Linux Commands – Part IV

42. lsb_release

The command ‘lsb_release‘ print distribution-specific information. If lsb_release is not installed, you can apt ‘lsb-core‘ on Debian or yum ‘redhat-lsb‘ on Red Hat the package.

# lsb_release -a

LSB Version:    :base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:
Distributor ID: CentOS
Description:    CentOS release 6.3 (Final)
Release:        6.3
Codename:       Final

Note: Option ‘-a‘, shows all the available information in respect of versioniddescriptionrelease and codename.

43. nc -zv localhost 80

Check if port 80 is open or not. We can replace ‘80‘ with any other port number to check if it is opened or closed.

$ nc -zv localhost 80

Connection to localhost 80 port [tcp/http] succeeded!

Check if port 8080 is open or not.

$ nc -zv localhost 8080

nc: connect to localhost port 8080 (tcp) failed: Connection refused

44. curl ipinfo.io

The below command will output the ‘Geographical Location‘ of the IP address, provided.

$ curl ipinfo.io 

"ip": "xx.xx.xx.xx",
"hostname": "triband-del-aa.bbb.cc.ddd.bol.net.in",
"city": null,
"region": null,
"country": "IN",
"loc": "20,77",
"org": "AS17813 Mahanagar Telephone Nigam Ltd."

45. find . -user root

The below command output the files with respect of the user (root) owned files. All the files owned by user ‘root’ in the current directory.

# find . -user root

./.recently-used.xbel
./.mysql_history
./.aptitude
./.aptitude/config
./.aptitude/cache
./.bluefish
./.bluefish/session-2.0
./.bluefish/autosave
./.bash_history

All the files owned by user ‘avi‘ in the current directory.

# find . -user avi

./.cache/chromium/Cache/f_002b66
./.cache/chromium/Cache/f_001719
./.cache/chromium/Cache/f_001262
./.cache/chromium/Cache/f_000544
./.cache/chromium/Cache/f_002e40
./.cache/chromium/Cache/f_00119a
./.cache/chromium/Cache/f_0014fc
./.cache/chromium/Cache/f_001b52
./.cache/chromium/Cache/f_00198d
./.cache/chromium/Cache/f_003680

46. sudo apt-get build-dep ffmpeg

The below command will build the dependency, automatically during the corresponding package installation. Hence the process of package installation is very much fluent and easy.

# apt-get build-dep ffmpeg

libxinerama-dev libxml-namespacesupport-perl libxml-sax-expat-perl
libxml-sax-perl libxml-simple-perl libxrandr-dev libxrender-dev
x11proto-render-dev x11proto-xinerama-dev xulrunner-dev
The following packages will be upgraded:
libpixman-1-0
1 upgraded, 143 newly installed, 0 to remove and 6 not upgraded.
Need to get 205 MB of archives.
After this operation, 448 MB of additional disk space will be used.
Do you want to continue [Y/n]?

47. lsof -iTCP:80 -sTCP:LISTEN

The below command outputs, name of process/service using a specific port 80. To better understand run the following command on port 80, it will list all services/processes running on port.

root@localhost:/home/avi# lsof -iTCP:80 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 1566 root 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1664 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1665 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1666 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1667 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1668 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)

Same way, you can also check the running services/processes of port 22.

root@localhost:/home/avi# lsof -iTCP:22 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 2261 root 3u IPv4 8366 0t0 TCP *:ssh (LISTEN)
sshd 2261 root 4u IPv6 8369 0t0 TCP *:ssh (LISTEN)

48. find -size +100M

The find command lists all the files in the current directory above the specified size (here 100 MB), recursively.

# find -size +100M

./.local/share/Trash/files/linuxmint-15-cinnamon-dvd-32bit.iso
./Downloads/Fedora-Live-Desktop-i686-19-1.iso
./Downloads/Ant Videos/shakira 2.avi
./Downloads/Deewar.avi
./Desktop/101MSDCF/MOV02224.AVI
./Desktop/101MSDCF/MOV02020.AVI
./Desktop/101MSDCF/MOV00406.MP4
./Desktop/squeeze.iso

Listing all the files whose size if more than 1000 MB, within current directory, recursively.

root@localhost:/home/avi# find -size +1000M

./Downloads/The Dark Knight 2008 hindi BRRip 720p/The Dark Knight.mkv.part
./Downloads/Saudagar - (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR]/Saudagar 
- (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR].mkv
./Downloads/Deewar.avi
./Desktop/squeeze.iso

49. pdftk

The pdftk command merges several pdf files into one. You must have installed pdftk program. If not, do apt or yum to get the required package.

$ pdftk 1.pdf 2.pdf 3.pdf …. 10.pdf cat output merged.pdf

50. ps -LF -u user_name

The below command outputs processes and threads of a user. The option “L” (list threads) and “-F” (Full Format Listing).

$ ps -LF -u avi

avi 21645 3717 21766 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 21645 3717 21768 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 22314 3717 22314 0 2 42797 50332 0 19:00 ? 00:00:40 /usr/
avi 22314 3717 22316 0 2 42797 50332 1 19:00 ? 00:00:00 /usr/
avi 22678 24621 22678 0 1 969 1060 1 21:05 pts/1 00:00:00 ps -L
avi 23051 3717 23051 0 2 37583 45444 1 19:03 ? 00:00:52 /usr/
avi 23051 3717 23053 0 2 37583 45444 0 19:03 ? 00:00:03 /usr/
avi 23652 1 23652 0 2 22092 12520 0 19:06 ? 00:00:22 gnome
avi 23652 1 23655 0 2 22092 12520 0 19:06 ? 00:00:00 gnome

51. Startx — :1

Sharing X session, means frequently logging in and out, this is where the Startx command comes to rescue. The command creates a new session thus no need to login and logout frequently from a session. In order to switch between the two X session, we need to switch between ‘ctrl+Alt+F7‘ and ‘ctrl+Alt+F8‘.

Note: The keys “ctrl+Alt+F1“, “ctrl+Alt+F6” is for console session, and “ctrl+Alt+F7“, “ctrl+Alt+F12” is for X session. Hence 6 console session and 6 X session, without frequent logging-in and out. The above sequence works on most of the distro, however different distro may have implemented it differently. I have checked it on Debian, and it works perfectly fine.

That’s all for now.

Source

How To Assign Output of a Linux Command to a Variable

When you run a command, it produces some kind of output: either the result of a program is suppose to produce or status/error messages of the program execution details. Sometimes, you may want to store the output of a command in a variable to be used in a later operation.

In this post, we will review the different ways of assigning the output of a shell command to a variable, specifically useful for shell scripting purpose.

To store the output of a command in a variable, you can use the shell command substitution feature in the forms below:

variable_name=$(command)
variable_name=$(command [option ...] arg1 arg2 ...)
OR
variable_name='command'
variable_name='command [option ...] arg1 arg2 ...'

Below are a few examples of using command substitution.

In this first example, we will store the value of who (which shows who is logged on the system) command in the variable CURRENT_USERS user:

$ CURRENT_USERS=$(who)

Then we can use the variable in a sentence displayed using the echo command like so:

$ echo -e "The following users are logged on the system:\n\n $CURRENT_USERS"

In the command above: the flag -e means interpret any escape sequences ( such as \n for newline) used. To avoid wasting time as well as memory, simply perform the command substitution within the echo command as follows:

$ echo -e "The following users are logged on the system:\n\n $(who)"

Shows Current Logged Users in Linux

Shows Current Logged Users in Linux

Next, to demonstrate the concept using the second form; we can store the total number of files in the current working directory in a variable called FILES and echo it later as follows:

$ FILES=`sudo find . -type f -print | wc -l`
$ echo "There are $FILES in the current working directory."

Show Number of Files in Directory

Show Number of Files in Directory

That’s it for now, in this article, we explained the methods of assigning the output of a shell command to a variable. You can add your thoughts to this post via the feedback section below.

Source

How to Undo or Redo a Yum Install on CentOS and RHEL

One of the most important and useful feature added to YUM Package Manager (from version 3.2.25) is the ‘yum history’ command. It allows you to review a full history of yum transactions that have been run on a system.

It shows the dates and times when a transactions were performed, whether the transactions succeeded or were aborted, the number of packages affected, and so much more.

Importantly, yum history can be used to undo or redo certain transactions. In this article, we will show how to undo or redo a yum install including dependencies on a CentOS/RHEL distribution.

To do this, first you need to review the yum transactions history by running the following command as root user, otherwise use the sudo command to gain root privileges.

$ sudo yum history  
OR
$ sudo yum history list all

List Yum History

List Yum History

From the output in the screenshot above, the yum history shows you the transaction ID, the command line, date and time, action and more.

To undo a yum install, take note of the transaction ID, and perform the required action. In this example, we want to undo the install with ID 63, which will erase the package that was installed in the specified transaction, as follows (enter y/yes when asked).

$ sudo yum history undo 63

Undo Yum Install Package

Undo Yum Install Package

To redo a yum install, as before, take note of the transaction ID, and run it. For instance to redo the install with ID 63, run the the following command.

$ sudo yum history redo 63

Note that you can do the same for a yum remove/erase transaction. The most important thing to note is the transaction ID of an yum install or yum remove action.

For more information about yum history, see this guide:

  1. How to Use ‘Yum History’ to Find Out Installed or Removed Packages Info

That’s all for now! In this article, we demonstrated how to undo or redo a yum install including dependencies on CentOS/RHEL. Share your thoughts with us via the comment form below.

Source

11 Ways to Find User Account Info and Login Details in Linux

This article will show you eleven useful ways to find the information about users on a Linux system. Here we’ll describe commands to get a user’s account details, show login details as well as what users are doing on the system.

Read AlsoHow to Monitor Linux Commands Executed by System Users in Real-time

If you want to add users in Linux, use the useradd utility, and to modify or change any attributes of a already created user account, use the usermod via the command line as explained in the following guides:

  1. 15 Useful Practical Examples on ‘useradd’ Command
  2. 15 Useful Practical Examples on ‘usermod’ Command

We’ll start by looking at commands to find a user’s account information, then proceed to explain commands to view login details.

1. id Command

id is a simple command line utility for displaying a real and effective user and group IDs as follows.

$ id tecmint 

uid=1000(tecmint) gid=1000(tecmint) groups=1000(tecmint),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),130(sambashare)

2. groups Command

groups command is used to show all the groups a user belongs to like this.

$ groups tecmint

tecmint : tecmint adm cdrom sudo dip plugdev lpadmin sambashare

3. finger Command

finger command is used to search information about a user on Linux. It doesn’t come per-installed on many Linux systems.

To install it on your system, run this command on the terminal.

$ sudo apt install finger	#Debian/Ubuntu 
$ sudo yum install finger	#RHEL/CentOS
$ sudo dnf install finger	#Fedora 22+

It shows a user’s real name; home directory; shell; login: name, time; and so much more as below.

$ finger tecmint

Login: tecmint        			Name: TecMint
Directory: /home/tecmint            	Shell: /bin/bash
On since Fri Sep 22 10:39 (IST) on tty8 from :0
   2 hours 1 minute idle
No mail.
No Plan.

4. getent Command

getent is a command line utility for fetching entries from Name Service Switch (NSS) libraries from a specific system database.

To get a user’s account details, use the passwd database and the username as follows.

$ getent passwd tecmint

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/bin/bash

5. grep Command

grep command is a powerful pattern searching tool available on most if not all Linus systems. You can use it to find information about a specific user from the system accounts file: /etc/passwd as shown below.

$ grep -i tecmint /etc/passwd

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/bin/bash

6. lslogins Command

lslogins command shows information about known users in the system, the -u flag only displays user accounts.

$ lslogins -u

UID USER       PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
   0 root        144                              root
1000 tecmint      70                     10:39:07 TecMint,,,
1001 aaronkilik    0                              
1002 john          0                              John Doo

7. users Command

users command shows the usernames of all users currently logged on the system like so.

$ users

tecmint
aaron

8. who Command

who command is used to display users who are logged on the system, including the terminals they are connecting from.

$ who -u

tecmint  tty8         2017-09-22 10:39 02:09        2067 (:0)

9. w Command

w command shows all users who are logged on the system and what they are doing.

$ w

12:46:54 up  2:10,  1 user,  load average: 0.34, 0.44, 0.57
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
tecmint  tty8     :0               10:39    2:10m  4:43   0.46s cinnamon-sessio

10. last or lastb commands

last/lastb commands displays a list of last logged in users on the system.

$ last 
OR
$ last -a   #show hostname on the last column
List of Last Logged Users
tecmint  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic
tecmint  tty8         Thu Sep 21 10:44 - down   (06:56)     :0
reboot   system boot  Thu Sep 21 10:42 - 17:40  (06:58)     4.4.0-21-generic
tecmint  tty8         Wed Sep 20 10:19 - down   (06:50)     :0
reboot   system boot  Wed Sep 20 10:17 - 17:10  (06:52)     4.4.0-21-generic
tecmint  pts/14       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%146
tecmint  pts/13       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%145
...

To show all the users who were present at a specified time, use the -p option as follows.

$ last -ap now

tecmint  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic

wtmp begins Fri Sep  1 16:23:02 2017

11. lastlog Command

lastlog command is used to find the details of a recent login of all users or of a given user as follows.

$ lastlog  
OR
$ lastlog -u tecmint 	#show lastlog records for specific user tecmint
Records of Recent Logged Users
Username         Port     From             Latest
root                                       **Never logged in**
kernoops                                   **Never logged in**
pulse                                      **Never logged in**
rtkit                                      **Never logged in**
saned                                      **Never logged in**
usbmux                                     **Never logged in**
mdm                                        **Never logged in**
tecmint          pts/1    127.0.0.1        Fri Jan  6 16:50:22 +0530 2017
..

That’s it! If you know any other command-line trick or command to view user account details do share with us.

You’ll find these related article so useful:

  1. How to Manage Users and Groups in Linux
  2. How to Delete User Accounts with Home Directory in Linux
  3. 3 Ways to Change Default User Shell in Linux
  4. How to Block or Disable User Logins in Linux

In this article, we’ve explained various ways to find information about users and login details on a Linux system.

 
Source

How to Save Top Command Output to a File

Linux top command is highly used by system administrators to display system statistics in real time regarding system uptime and load averageused memoryrunning tasks, a summary of processes or threads and detailed information about each running process.

However, besides real time viewing of the running system, top command output can be saved to a file, by using the -b flag, which instructs top to operate in batch mode and -n flag to specify the amount of iteration the command should output.

In the below example, we’ll redirect the output of top command to top.txt file in the current working directory. The -n argument will be used to send only one snapshot of the command to the mentioned file.

$ top -b -n 1 > top.txt

To read the resulted file, use a command line file reader utility, such as cat commandless or more.

$ less top.txt

View Output of Top Command

View Output of Top Command

To grab five iteration of top command, execute the command as shown in the below excerpt.

$ top -b -n 5 > top-5iterations.txt

In order to display only the number of running tasks from the resulted file, use the grep filter, as shown in the below command example.

$ cat top-5iterations.txt | grep Tasks

Show Top 5 Running Tasks

Show Top 5 Running Tasks

To take a snapshot of a specific process in top utility, execute command with the PID (-p) flag. To get the PID of a running process, issue pidof command against the name of the running process.

In this example we’ll monitor the cron process via top command by taking three snapshots of the PID.

$ pidof crond
$ top -p 678 -b -n3 > cron.txt
$ cat cron.txt

Watch Process Usage in Top Command

Watch Process Usage in Top Command

Using a for iteration loop, we can display a process statistics via its PID, each two seconds, as shown in the below example. The output of the loop can also be redirected to a file. We’ll use the same cron PID as shown in the above example.

$ for i in {1..4}; do sleep 2 && top -b -p 678 -n1 | tail -1 ; done	

Redirect loop output to file.

$ for i in {1..4}; do sleep 2 && top -b -p 678 -n1 | tail -1 ; done >> cron.txt
$ cat cron.txt

Find Linux Process Statistics

Find Linux Process Statistics

These are just a few examples on how you can monitor and gather system and process statistics via top command.

Source

How to Find MySQL, PHP and Apache Configuration Files

In this post, we will learn a number of commands for locating the default configuration files for MySQL database server (my.conf), PHP programming language (php.ini) and Apache HTTP server (http.conf), which together with Linux form the LAMP (Linux Apache Mysql/MariaDB PHP) stack.

A configuration file (or config file) contains system related or application settings. It gives developers and administrators control over operation of the system or an application.

As a Linux Sysadmin, knowing the location of configuration files or mastering means of finding them is an invaluable skill.

In Linux Directory Structure, the /etc directory or its sub-directories store system related or application configuration files.

Although this is the primary location of configuration files, a few developers choose to store other configuration files in custom directories.

How To Find MySQL (my.conf) Configuration File

You can locate the the MySQL configuration file using the mysql command line tool or mysqladmin, a client for managing a MySQL server.

The following commands will display the mysql or mysqladmin help page, which includes a section that talks about the files (configuration files) from which default options are read.

In the commands below, the grep option -A displays NUM lines of trailing context after matching lines.

$ mysql --help | grep -A1 'Default options'
OR
$ mysqladmin --help | grep -A1 'Default options'

Find MySQL my.cnf Configuration File

Find MySQL my.cnf Configuration File

Make an effort to master the MySQL administration through these helpful articles.

  1. Learn MySQL for Beginners Guide – Part 1
  2. Learn MySQL for Beginners Guide – Part 2
  3. 20 Useful Mysqladmin Commands for Database Administration

How To Find PHP (php.ini) Configuration File

PHP can be controlled from the terminal using php command line utility, in conjunction with the -i switch which enables showing of PHP information and configurations and grep command help you to can find the PHP configuration file like so:

$ php -i | grep "Loaded Configuration File"

Find PHP (php.ini) Configuration File

Find PHP (php.ini) Configuration File

Find Apache http.conf/apache2.conf Configuration File

You can invoke apache2 directly (which is not recommended in most cases) or administer it using apache2ctlcontrol interface as below with the -V flag which shows the version and build parameters of apache2:

--------- On CentOS/RHEL/Fedora ---------
$ apachectl -V | grep SERVER_CONFIG_FILE

--------- On Debian/Ubuntu/Linux Mint ---------
$ apache2ctl -V | grep SERVER_CONFIG_FILE

Find Apache Configuration File

Find Apache Configuration File

That’s all! Remember to share your thoughts about this post or provide us other possible ways of locating the above configuration files in the comments.

Source

Manage Files Effectively using head, tail and cat Commands in Linux

There are several commands and programs provided by Linux for viewing the contents of file. Working with files is one of the daunting task, most of the computer users be it newbie, regular user, advanced user, developer, admin, etc performs. Working with files effectively and efficiently is an art.

View Content of Files in Linux

Manage Files in Linux

Today, in this article we will be discussing the most popular commands called headtail and cat, most of us already aware of such commands, but very few of us implement it when needed.

1. head Command

The head command reads the first ten lines of a any given file name. The basic syntax of head command is:

head [options] [file(s)]

For example, the following command will display the first ten lines of the file named ‘/etc/passwd‘.

# head /etc/passwd 

root:x:0:0:root:/root:/bin/bash 
daemon:x:1:1:daemon:/usr/sbin:/bin/sh 
bin:x:2:2:bin:/bin:/bin/sh 
sys:x:3:3:sys:/dev:/bin/sh 
sync:x:4:65534:sync:/bin:/bin/sync 
games:x:5:60:games:/usr/games:/bin/sh 
man:x:6:12:man:/var/cache/man:/bin/sh 
lp:x:7:7:lp:/var/spool/lpd:/bin/sh 
mail:x:8:8:mail:/var/mail:/bin/sh 
news:x:9:9:news:/var/spool/news:/bin/sh

If more than one file is given, head will show the first ten lines of each file separately. For example, the following command will show ten lines of each file.

# head /etc/passwd /etc/shadow

==> /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 adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin ==> /etc/shadow <==
root:$6$85e1:15740:0:99999:7:::
bin:*:15513:0:99999:7:::
daemon:*:15513:0:99999:7:::
adm:*:15513:0:99999:7:::
lp:*:15513:0:99999:7:::
sync:*:15513:0:99999:7:::
shutdown:*:15513:0:99999:7:::
halt:*:15513:0:99999:7:::
mail:*:15513:0:99999:7:::
uucp:*:15513:0:99999:7:::

If it is desired to retrieve more number of lines than the default ten, then ‘-n‘ option is used along with an integer telling the number of lines to be retrieved. For example, the following command will display first 5 lines from the file ‘/var/log/yum.log‘ file.

# head -n5 /var/log/yum.log

Jan 10 00:06:49 Updated: openssl-1.0.1e-16.el6_5.4.i686
Jan 10 00:06:56 Updated: openssl-devel-1.0.1e-16.el6_5.4.i686
Jan 10 00:11:42 Installed: perl-Net-SSLeay-1.35-9.el6.i686
Jan 13 22:13:31 Installed: python-configobj-4.6.0-3.el6.noarch
Jan 13 22:13:36 Installed: terminator-0.95-3.el6.rf.noarch

In fact, there is no need to use ‘-n‘ option. Just the hyphen and specify the integer without spaces to get the same result as the above command.

# head  -5 /var/log/yum.log

Jan 10 00:06:49 Updated: openssl-1.0.1e-16.el6_5.4.i686
Jan 10 00:06:56 Updated: openssl-devel-1.0.1e-16.el6_5.4.i686
Jan 10 00:11:42 Installed: perl-Net-SSLeay-1.35-9.el6.i686
Jan 13 22:13:31 Installed: python-configobj-4.6.0-3.el6.noarch
Jan 13 22:13:36 Installed: terminator-0.95-3.el6.rf.noarch

The head command can also display any desired number of bytes using ‘-c‘ option followed by the number of bytes to be displayed. For example, the following command will display the first 45 bytes of given file.

# head -c45 /var/log/yum.log

Jan 10 00:06:49 Updated: openssl-1.0.1e-16.el

2. tail Command

The tail command allows you to display last ten lines of any text file. Similar to the head command above, tail command also support options  ‘n‘ number of lines and ‘n‘ number of characters.

The basic syntax of tail command is:

# tail [options] [filenames]

For example, the following command will print the last ten lines of a file called ‘access.log‘.

# tail access.log 

1390288226.042      0 172.16.18.71 TCP_DENIED/407 1771 GET http://download.newnext.me/spark.bin? - NONE/- text/html
1390288226.198      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html
1390288226.210   1182 172.16.20.44 TCP_MISS/200 70872 GET http://mahavat.gov.in/Mahavat/index.jsp pg DIRECT/61.16.223.197 text/html
1390288226.284     70 172.16.20.44 TCP_MISS/304 269 GET http://mahavat.gov.in/Mahavat/i/i-19.gif pg DIRECT/61.16.223.197 -
1390288226.362    570 172.16.176.139 TCP_MISS/200 694 GET http://p4-gayr4vyqxh7oa-3ekrqzjikvrczq44-if-v6exp3-v4.metric.gstatic.com/v6exp3/redir.html pg 
1390288226.402      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html
1390288226.437    145 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html
1390288226.445      0 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html
1390288226.605      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html
1390288226.808      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html

If more than one file is provided, tail will print the last ten lines of each file as shown below.

# tail access.log error.log

==> access.log <== 1390288226.042      0 172.16.18.71 TCP_DENIED/407 1771 GET http://download.newnext.me/spark.bin? - NONE/- text/html 1390288226.198      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html 1390288226.210   1182 172.16.20.44 TCP_MISS/200 70872 GET http://mahavat.gov.in/Mahavat/index.jsp pg DIRECT/61.16.223.197 text/html 1390288226.284     70 172.16.20.44 TCP_MISS/304 269 GET http://mahavat.gov.in/Mahavat/i/i-19.gif pg DIRECT/61.16.223.197 - 1390288226.362    570 172.16.176.139 TCP_MISS/200 694 GET http://p4-gayr4vyqxh7oa-3ekrqzjikvrczq44-if-v6exp3-v4.metric.gstatic.com/v6exp3/redir.html pg  1390288226.402      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html 1390288226.437    145 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html 1390288226.445      0 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html 1390288226.605      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html 1390288226.808      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html ==> error_log <==
[Sun Mar 30 03:16:03 2014] [notice] Digest: generating secret for digest authentication ...
[Sun Mar 30 03:16:03 2014] [notice] Digest: done
[Sun Mar 30 03:16:03 2014] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 mod_ssl/2.2.15 OpenSSL/1.0.0-fips configured -- resuming normal operations

Similarly, you can also print the last few lines using the ‘-n‘ option as shown below.

# tail -5 access.log

1390288226.402      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html
1390288226.437    145 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html
1390288226.445      0 172.16.18.53 TCP_DENIED/407 1723 OPTIONS http://172.16.25.252/ - NONE/- text/html
1390288226.605      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html
1390288226.808      0 172.16.16.55 TCP_DENIED/407 1753 CONNECT ent-shasta-rrs.symantec.com:443 - NONE/- text/html

You can also print the number of characters using ‘-c’ argument as shown below.

# tail -c5 access.log

ymantec.com:443 - NONE/- text/html

3. cat Command

The ‘cat‘ command is most widely used, universal tool. It copies standard input to standard output. The command supports scrolling, if text file doesn’t fit the current screen.

The basic syntax of cat command is:

# cat [options] [filenames] [-] [filenames]

The most frequent use of cat is to read the contents of files. All that is required to open a file for reading is to type cat followed by a space and the file name.

# cat /etc/passwd 

root:x:0:0:root:/root:/bin/bash 
daemon:x:1:1:daemon:/usr/sbin:/bin/sh 
bin:x:2:2:bin:/bin:/bin/sh 
sys:x:3:3:sys:/dev:/bin/sh 
sync:x:4:65534:sync:/bin:/bin/sync 
games:x:5:60:games:/usr/games:/bin/sh 
man:x:6:12:man:/var/cache/man:/bin/sh 
lp:x:7:7:lp:/var/spool/lpd:/bin/sh 
…

The cat command also used to concatenate number of files together.

# echo 'Hi Tecmint-Team' > 1 
# echo 'Keep connected' > 2 
# echo 'Share your thought' > 3 
# echo 'connect us tecmint.com@gmail.com' > 4
# cat 1 2 3 4 > 5
# cat 5 

Hi Tecmint-Team 
Keep connected 
Share your thought 
connect us tecmint.com@gmail.com

It can be also used to create files as well. It is achieved by executing cat followed by the output redirection operator and the file name to be created.

# cat > tecmint.txt

Tecmint is the only website fully dedicated to Linux.

We can have custom end maker for ‘cat’ command. Here it is implemented.

# cat > test.txt << end 

I am Avishek 
Here i am writing this post 
Hope your are enjoying 
end
# cat test.txt 

I am Avishek 
Here i am writing this post 
Hope your are enjoying

Never underestimate the power of  ‘cat’ command and can be useful for copying files.

# cat avi.txt

I am a Programmer by birth and Admin by profession
# cat avi.txt > avi1.txt
# cat avi1.txt

I am a Programmer by birth and Admin by profession

Now what’s the opposite of cat? Yeah it’s ‘tac‘. ‘tac‘ is a command under Linux. It is better to show an example of ‘tac’ than to talk anything about it.

Create a text file with the names of all the month, such that one word appears on a line.

# cat month

January
February
March
April
May
June
July
August
September
October
November
December
# tac month

December
November
October
September
August
July
June
May
April
March
February
January

For more examples of cat command usage, refer to the 13 cat Command Usage

That’s all for now.

Source

Learn Why ‘less’ is Faster Than ‘more’ Command for Effective File Navigation

More is a *nix command line used to display the contents of a file in a console. The basic usage of morecommand is to run the command against a file as shown below:

Read Also: Learn Difference Between ‘cat’ and ‘tac’ Commands with Examples

Learn Linux ‘more’ Command

# more /var/log/auth.log
View Contents of auth.log File
Apr 12 11:50:01 tecmint CRON[6932]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 11:50:01 tecmint CRON[6932]: pam_unix(cron:session): session closed for user root
Apr 12 11:55:01 tecmint CRON[7159]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 11:55:01 tecmint CRON[7160]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 11:55:01 tecmint CRON[7160]: pam_unix(cron:session): session closed for user root
Apr 12 11:55:02 tecmint CRON[7159]: pam_unix(cron:session): session closed for user root
Apr 12 12:00:01 tecmint CRON[7290]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:00:01 tecmint CRON[7290]: pam_unix(cron:session): session closed for user root
Apr 12 12:05:01 tecmint CRON[7435]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:05:01 tecmint CRON[7436]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:05:01 tecmint CRON[7436]: pam_unix(cron:session): session closed for user root
Apr 12 12:05:02 tecmint CRON[7435]: pam_unix(cron:session): session closed for user root
Apr 12 12:09:01 tecmint CRON[7542]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:09:01 tecmint CRON[7542]: pam_unix(cron:session): session closed for user root
Apr 12 12:10:01 tecmint CRON[7577]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:10:01 tecmint CRON[7577]: pam_unix(cron:session): session closed for user root
Apr 12 12:15:01 tecmint CRON[7699]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:15:01 tecmint CRON[7700]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 12:15:01 tecmint CRON[7700]: pam_unix(cron:session): session closed for user root
Apr 12 12:15:01 tecmint CRON[7699]: pam_unix(cron:session): session closed for user root
....

Another way to use more command in conjunction (pipe) with other commands, such as cat command, as presented on below example:

# cat /var/log/auth.log | more

View and Navigate Contents of File

View and Navigate Contents of File

In order to navigate through the file line by line press Enter key or press Spacebar key to navigate one page at a time, the page being your current terminal screen size. To exit the command just press q key.

A useful option of more command is the -number switch which allows you to set the number of line a page should contain. As an example display the auth.log file as a page of 10 lines:

# more -10 /var/log/auth.log

Show Only First 10 Lines of File

Show Only First 10 Lines of File

Also, you can display a page starting from a specific line number using the +number option as illustrated below:

# more +14 /var/log/auth.log
Show Only First 14 Lines of auth.log File
Apr 12 12:09:01 tecmint CRON[7542]: pam_unix(cron:session): session closed for user root
Apr 12 12:10:01 tecmint CRON[7577]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:10:01 tecmint CRON[7577]: pam_unix(cron:session): session closed for user root
Apr 12 12:15:01 tecmint CRON[7699]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:15:01 tecmint CRON[7700]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:15:01 tecmint CRON[7700]: pam_unix(cron:session): session closed for user root
Apr 12 12:15:01 tecmint CRON[7699]: pam_unix(cron:session): session closed for user root
Apr 12 12:16:01 tecmint mate-screensaver-dialog: gkr-pam: unlocked login keyring
Apr 12 12:17:01 tecmint CRON[7793]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:17:01 tecmint CRON[7793]: pam_unix(cron:session): session closed for user root
Apr 12 12:20:01 tecmint CRON[7905]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:20:01 tecmint CRON[7905]: pam_unix(cron:session): session closed for user root
Apr 12 12:25:01 tecmint CRON[8107]: pam_unix(cron:session): session opened for user root by (
uid=0)
Apr 12 12:25:01 tecmint CRON[8108]: pam_unix(cron:session): session opened for user root by (

Learn Linux ‘less’ Command

Similar to moreless command allows you to view the contents of a file and navigate through file. The main difference between more and less is that less command is faster because it does not load the entire file at once and allows navigation though file using page up/down keys.

In can be used as a standalone command issued against a file or used with pipes with a multitude of Linux commands in order to narrow their screen output allowing you to scroll through results.

# less /var/log/auth.log
# ls /etc | less

You can navigate through the file line by line pressing Enter key. Page navigation can be handled with spacebar key. The page size is represented by your current terminal screen size. To exit command type q key, same way as for more command.

A useful feature of less command is the use of /word-to-seach option. For instance you can search and match all sshd messages from a log file by interactively specifying the /sshd string.

View File Content Using less Command

View File Content Using less Command

In order to display a file staring at a specific line number use the following syntax:

# less +5 /var/log/auth.log

If you need to track down the number of every line with less command use the -N option.

# less -N /var/log/daemon.log
Show Number for Every Line in File
      1 Apr 12 11:50:01 tecmint CRON[6932]: pam_unix(cron:session): session opened for user root by (uid=0)
      2 Apr 12 11:50:01 tecmint CRON[6932]: pam_unix(cron:session): session closed for user root
      3 Apr 12 11:55:01 tecmint CRON[7159]: pam_unix(cron:session): session opened for user root by (uid=0)
      4 Apr 12 11:55:01 tecmint CRON[7160]: pam_unix(cron:session): session opened for user root by (uid=0)
      5 Apr 12 11:55:01 tecmint CRON[7160]: pam_unix(cron:session): session closed for user root
      6 Apr 12 11:55:02 tecmint CRON[7159]: pam_unix(cron:session): session closed for user root
      7 Apr 12 12:00:01 tecmint CRON[7290]: pam_unix(cron:session): session opened for user root by (uid=0)
      8 Apr 12 12:00:01 tecmint CRON[7290]: pam_unix(cron:session): session closed for user root
      9 Apr 12 12:05:01 tecmint CRON[7435]: pam_unix(cron:session): session opened for user root by (uid=0)
     10 Apr 12 12:05:01 tecmint CRON[7436]: pam_unix(cron:session): session opened for user root by (uid=0)
     11 Apr 12 12:05:01 tecmint CRON[7436]: pam_unix(cron:session): session closed for user root

By default the only way to exit less command is to hit q key. To change this behavior and automatically exit file when reaching the end of file use the -e or -E option:

# less -e /var/log/auth.log
# less -E /var/log/auth.log

To open a file at the first occurrence of a pattern use the following syntax:

# less +/sshd /var/log/auth.log
Show Given Matching String in File
Apr 12 16:19:39 tecmint sshd[16666]: Accepted password for tecmint from 192.168.0.15 port 41634 ssh2
Apr 12 16:19:39 tecmint sshd[16666]: pam_unix(sshd:session): session opened for user tecmint by (uid=0)
Apr 12 16:19:39 tecmint systemd-logind[954]: New session 1 of user tecmint.
Apr 12 16:19:48 tecmint sshd[16728]: Received disconnect from 192.168.0.15: 11: disconnected by user
Apr 12 16:19:48 tecmint sshd[16666]: pam_unix(sshd:session): session closed for user tecmint
Apr 12 16:20:01 tecmint CRON[16799]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 16:20:02 tecmint CRON[16799]: pam_unix(cron:session): session closed for user root
Apr 12 16:25:01 tecmint CRON[17026]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 12 16:25:01 tecmint CRON[17025]: pam_unix(cron:session): session opened for user root by (uid=0)

The above command tells less to open auth.log file at the first match of sshd string.

In order to automatically append the content of a file opened in less command use the Shift+f keys combination or run less with the following syntax.

# less +F /var/log/syslog

This makes less to run in interactive mode (live) and display new content on-fly while waiting for new data to be written to file. This behavior is similar to tail -f command.

In combination with a pattern you can watch the log file interactively with Shift+f key stroke while matching a keyword. To exit live mode just press Ctrl+c keys.

# less +/CRON /var/log/syslog

Whether you decide to use more or less, which is a personal choice, remember that less is more with morefeatures.

Read Also: Manage Files Effectively Using head, tail and cat Commands

Source

fdupes – A Command Line Tool to Find and Delete Duplicate Files in Linux

It is a common requirement to find and replace duplicate files for most of the computer users. Finding and removing duplicate files is a tiresome job that demands time and patience. Finding duplicate files can be very easy if your machine is powered by GNU/Linux, thanks to ‘fdupes‘ utility.

Find and Delete Duplicate Files in Linux

Fdupes – Find and Delete Duplicate Files in Linux

What is fdupes?

Fdupes is a Linux utility written by Adrian Lopez in C programming Language released under MIT License. The application is able to find duplicate files in the given set of directories and sub-directories. Fdupes recognize duplicates by comparing MD5 signature of files followed by a byte-to-byte comparison. A lots of options can be passed with Fdupes to list, delete and replace the files with hardlinks to duplicates.

The comparison starts in the order:

size comparison > Partial MD5 Signature Comparison > Full MD5 Signature Comparison > Byte-to-Byte Comparison.

Install fdupes on a Linux

Installation of latest version of fdupes (fdupes version 1.51) as easy as running following command on Debianbased systems such as Ubuntu and Linux Mint.

$ sudo apt-get install fdupes

On CentOS/RHEL and Fedora based systems, you need to turn on epel repository to install fdupes package.

# yum install fdupes
# dnf install fdupes    [On Fedora 22 onwards]

Note: The default package manager yum is replaced by dnf from Fedora 22 onwards…

How to use fdupes command?

1. For demonstration purpose, let’s a create few duplicate files under a directory (say tecmint) simply as:

$ mkdir /home/"$USER"/Desktop/tecmint && cd /home/"$USER"/Desktop/tecmint && for i in {1..15}; do echo "I Love Tecmint. Tecmint is a very nice community of Linux Users." > tecmint${i}.txt ; done

After running above command, let’s verify the duplicates files are created or not using ls command.

$ ls -l

total 60
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint10.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint11.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint12.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint13.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint14.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint15.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint1.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint2.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint3.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint4.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint5.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint6.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint7.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint8.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9.txt

The above script create 15 files namely tecmint1.txt, tecmint2.txt…tecmint15.txt and every files contains the same data i.e.,

"I Love Tecmint. Tecmint is a very nice community of Linux Users."

2. Now search for duplicate files within the folder tecmint.

$ fdupes /home/$USER/Desktop/tecmint 

/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

3. Search for duplicates recursively under every directory including it’s sub-directories using the -r option.

It search across all the files and folder recursively, depending upon the number of files and folders it will take some time to scan duplicates. In that mean time, you will be presented with the total progress in terminal, something like this.

$ fdupes -r /home

Progress [37780/54747] 69%

4. See the size of duplicates found within a folder using the -S option.

$ fdupes -S /home/$USER/Desktop/tecmint

65 bytes each:                          
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

5. You can see the size of duplicate files for every directory and subdirectories encountered within using the -Sand -r options at the same time, as:

$ fdupes -Sr /home/avi/Desktop/

65 bytes each:                          
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

107 bytes each:
/home/tecmint/Desktop/resume_files/r-csc.html
/home/tecmint/Desktop/resume_files/fc.html

6. Other than searching in one folder or all the folders recursively, you may choose to choose in two folders or three folders as required. Not to mention you can use option -S and/or -r if required.

$ fdupes /home/avi/Desktop/ /home/avi/Templates/

7. To delete the duplicate files while preserving a copy you can use the option ‘-d’. Extra care should be taken while using this option else you might end up loosing necessary files/data and mind it the process is unrecoverable.

$ fdupes -d /home/$USER/Desktop/tecmint

[1] /home/tecmint/Desktop/tecmint/tecmint13.txt
[2] /home/tecmint/Desktop/tecmint/tecmint8.txt
[3] /home/tecmint/Desktop/tecmint/tecmint11.txt
[4] /home/tecmint/Desktop/tecmint/tecmint3.txt
[5] /home/tecmint/Desktop/tecmint/tecmint4.txt
[6] /home/tecmint/Desktop/tecmint/tecmint6.txt
[7] /home/tecmint/Desktop/tecmint/tecmint7.txt
[8] /home/tecmint/Desktop/tecmint/tecmint9.txt
[9] /home/tecmint/Desktop/tecmint/tecmint10.txt
[10] /home/tecmint/Desktop/tecmint/tecmint2.txt
[11] /home/tecmint/Desktop/tecmint/tecmint5.txt
[12] /home/tecmint/Desktop/tecmint/tecmint14.txt
[13] /home/tecmint/Desktop/tecmint/tecmint1.txt
[14] /home/tecmint/Desktop/tecmint/tecmint15.txt
[15] /home/tecmint/Desktop/tecmint/tecmint12.txt

Set 1 of 1, preserve files [1 - 15, all]:

You may notice that all the duplicates are listed and you are prompted to delete, either one by one or certain range or all in one go. You may select a range something like below to delete files files of specific range.

Set 1 of 1, preserve files [1 - 15, all]: 2-15

   [-] /home/tecmint/Desktop/tecmint/tecmint13.txt
   [+] /home/tecmint/Desktop/tecmint/tecmint8.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint11.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint3.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint4.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint6.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint7.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint9.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint10.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint2.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint5.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint14.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint1.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint15.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint12.txt

8. From safety point of view, you may like to print the output of ‘fdupes’ to file and then check text file to decide what file to delete. This decrease chances of getting your file deleted accidentally. You may do:

$ fdupes -Sr /home > /home/fdupes.txt

Note: You may replace ‘/home’ with the your desired folder. Also use option ‘-r’ and ‘-S’ if you want to search recursively and Print Size, respectively.

9. You may omit the first file from each set of matches by using option ‘-f’.

First List files of the directory.

$ ls -l /home/$USER/Desktop/tecmint

total 20
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (3rd copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (4th copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (another copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9.txt

and then omit the first file from each set of matches.

$ fdupes -f /home/$USER/Desktop/tecmint

/home/tecmint/Desktop/tecmint9 (copy).txt
/home/tecmint/Desktop/tecmint9 (3rd copy).txt
/home/tecmint/Desktop/tecmint9 (another copy).txt
/home/tecmint/Desktop/tecmint9 (4th copy).txt

10. Check installed version of fdupes.

$ fdupes --version

fdupes 1.51

11. If you need any help on fdupes you may use switch ‘-h’.

$ fdupes -h

Usage: fdupes [options] DIRECTORY...

 -r --recurse     	for every directory given follow subdirectories
                  	encountered within
 -R --recurse:    	for each directory given after this option follow
                  	subdirectories encountered within (note the ':' at
                  	the end of the option, manpage for more details)
 -s --symlinks    	follow symlinks
 -H --hardlinks   	normally, when two or more files point to the same
                  	disk area they are treated as non-duplicates; this
                  	option will change this behavior
 -n --noempty     	exclude zero-length files from consideration
 -A --nohidden    	exclude hidden files from consideration
 -f --omitfirst   	omit the first file in each set of matches
 -1 --sameline    	list each set of matches on a single line
 -S --size        	show size of duplicate files
 -m --summarize   	summarize dupe information
 -q --quiet       	hide progress indicator
 -d --delete      	prompt user for files to preserve and delete all
                  	others; important: under particular circumstances,
                  	data may be lost when using this option together
                  	with -s or --symlinks, or when specifying a
                  	particular directory more than once; refer to the
                  	fdupes documentation for additional information
 -N --noprompt    	together with --delete, preserve the first file in
                  	each set of duplicates and delete the rest without
                  	prompting the user
 -v --version     	display fdupes version
 -h --help        	display this help message

That’s for all now. Let me know how you were finding and deleting duplicates files till now in Linux? and also tell me your opinion about this utility. Put your valuable feedback in the comment section below and don’t forget to like/share us and help us get spread.

I am working on another utility called fslint to remove duplicate files, will soon post and you people will love to read.

Source

WP2Social Auto Publish Powered By : XYZScripts.com