Did You Know?
Donate to TecMint

LFCS - Linux Foundation Certified SysAdmin - Exam Preparation Guide

10 Lesser Known Linux Commands – Part 2

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators

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 history command.

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 ls, pwd, uname, echo “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 Size, Blocks, Access Permission, Date-time of file last access, Modify, change, 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)>(.*)<\/\1>/;'
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
I am a major in computer science, love to research nix. I love to write codes and scripts, review distros, experiment Foss Technologies, write technical articles, Hack, of course Ethically. I am working as System Administrator (nix) for a NGO.

Your name can also be listed here. Work as a Paid freelancer/writer at TecMint.
Download Free eBooks
Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Ubuntu Linux Toolbox: 1000+ Commands

23 Responses

  1. Thx a ton…

    sudo !! : were re-typing in agony :) before
    shuf : were using ‘sort -R |head -n1′
    mount | column -t : looked like a pile of ..it before
    history cheat : didn’t work; don’t know why. happy with HISTFILE=/dev/null

    • Avishek Kumar says:

      Welcome @ Rony B Chandran.

      will you please, provide us with details of input/output of the command not working on your box, so that we could understand it better.

  2. Jed says:

    Thanks for these tips! I really like the “column -t” command. Amazing things are tucked away in /usr, aren’t they?

  3. Prasad says:

    Thanks for sharing. file command also use for check binary file 32 bit or 64 bit. Please let me know how to use “column” command.

    • Avishek Kumar says:

      Welcome @ Prasad.

      well were not we very clear with above commands specially ‘column’ command. Please read the column command description above as well as man page, and let us know where we could help you.

  4. Wilecoyote7 says:

    No love for the ‘type’ command? If you want to know where a command is in the system, or if it’s an internal command, use ‘type’ and the name of the command:
    type bash
    or
    type help
    It will show you where the command resides. It is similar to the ‘whereis’ command that finds files as well (but shows any files that contain the name:
    whereis bash
    whereis fdisk

    Just my two cents……

  5. hesco says:

    screen is nice, but I left it behind for tmux.
    See: http://tmux.sourceforge.net/
    which I find a bit easier to use.

    Both permit remote pairing in a shared session.
    Both are complex and featureful.

    Pragmattic Programmer offers an excellent book:
    http://pragprog.com/book/bhtmux/tmux

    Well worth even a minimal investment in its learning curve.
    And the more time I spend with that book
    (which I still have not read cover-to-cover)
    the more I get out of it.

    — Hugh

  6. Croitoru Radu-Bogdan says:

    % stat -c “%a %n” * | column -t

  7. Denver says:

    For “12. Command” isn’t really cheating the history command and is likely due to either the HISTCONTROL variable being set to “ignorespace” or setting HISTIGNORE to include white space with the bash shell.

    -denver

  8. Kenyon Ralph says:

    “12” is not a command, it’s a non-default feature of the shell, which I’m assuming is bash here. Look for the HISTCONTROL variable in the bash reference manual.

  9. Eddie G. says:

    Thanks for these…although some of them didn’t work…is it because I’m using Fedora Linux?…or is there something I need to type before the prompt?….should I be running these as root…or do I have to do the “sudo” thing before typing them?….thanks anyway!!

    • Avishek Kumar says:

      @ Eddie G. please let us know which commands didn’t work for you so that we resolve your issue, in details please.

      Also make sure your shell is BASH.

  10. Admin says:

    The “pv” is the one :) Thanks a bunch for this post, awesome examples!

    • Avishek Kumar says:

      @ Admin (dont know what’s your Real name) Thanks for your valueable feedback.

      comment of such kind makes us feel “Awesome” (Specially me, as a writer.)

  11. Vijay says:

    Liked column -t and pv

  12. Unnikrishnan says:

    command is not working. In history , the command is showing with white space :) :P am in centos 6

  13. Gunnar says:

    Screen is a nice tool indeed, although tmux is worth a look. The session management is far more stable imo. Thanks for showing the other commands, didn’t know all of them yet :)

    • Avishek Kumar says:

      Thanks @ Gunnar, for your feedback, sure would write an article on tmux, You can also contribute an article on tmux, if you are very much familiar with the application.

      And there exists a lot of things in/about Linux, none of us know :)

Leave a Reply

This work is licensed under a (cc) BY-NC | TecMint uses cookies. By using our services, you comply to use of our cookies. More info: Privacy Policy.
© 2012-2014 All Rights Reserved.