51 Useful Lesser Known Commands for Linux Users

Linux is known for its vast set of powerful command-line tools that allow users to interact efficiently with the system. While many Linux users are familiar with popular commands like ls, cd, or grep, there are lesser-known but extremely useful commands and shortcuts that can simplify and improve productivity.

We’re happy to share our last five articles on ‘Lesser Known Linux Commands‘, which include more than 50 commands you may not know.

This article puts all five together in one easy guide, giving a short summary of each command, its function, and an example.

1. sudo !!

If you forgot to run a command with sudo, you don’t need to rewrite the whole command. Just type sudo !! and it will execute the last command with sudo.

apt update
Permission denied
sudo !!
sudo apt update

2. python -m SimpleHTTPServer

Creates a simple web page for the current working directory on port 8000.

python -m SimpleHTTPServer

Serving HTTP on 0.0.0.0 port 8000 ...

3. mtr Command

Combines ping and traceroute to show the network status in real time.

mtr google.com

4. Ctrl+x+e

Opens the terminal’s default text editor, allowing you to edit the current command before running it.

For example, Press Ctrl+x followed by e in the terminal to open the command in an editor.

5. nl Command

Outputs the content of a text file with line numbers.

nl file.txt

1   This is line 1
2   This is line 2

6. shuf Command

Randomly selects lines from a file or shuffles the content.

shuf -n 3 file.txt

7. ss Command

Displays socket statistics and active connections.

ss -tuln

8. last Command

Displays the history of last logged-in users.

last

9. curl ifconfig.me

Shows the machine’s external IP address.

curl ifconfig.me

10. tree Command

Displays files and directories in a tree-like structure.

tree

11. pstree

Displays a hierarchical view of running processes.

pstree

12. <space> Command

Prevents the command from being saved in the history.

<space> ls

13. stat Command

Displays detailed status information of a file or filesystem.

stat file.txt

14. <alt>. and <esc> .

Reuses the last argument of the previous command.

echo foo
<alt>.

15. pv Command

Simulates Hollywood-style text streams.

echo "Loading..." | pv -qL 10

16. mount | column -t

Displays mounted filesystems in a well-formatted manner.

mount | column -t

17. Ctrl + l

Clears the terminal screen instantly by pressing Ctrl + l in the terminal.

18. curl Command

Fetches unread Gmail messages in the terminal.

curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "$1\n" if /<title>(.*)<\/title>/'

19. screen Command

Detaches and reattaches long-running processes from the terminal.

screen -S session_name

20. file Command

Identifies the type of a file.

file file.txt

21. id Command

Prints user and group ID information.

id

22. ^foo^bar

Replaces foo with bar in the previous command.

echo foo
^foo^bar

23. > file.txt

Flushes the content of a file from the command prompt.

> file.txt

24. at Command

Schedules commands to be run at a later time.

echo "shutdown now" | at 23:00

25. du Command

Shows the size of files and folders within the current directory.

du -h --max-depth=1

26. expr Command

Solves simple mathematical calculations in the terminal.

expr 3 + 5

27. look Command

Checks for a word in the dictionary.

look apple

28. yes Command

Repeatedly outputs a string until interrupted.

yes "I will study Linux!"

29. factor Command

Shows all the factors of a given number.

factor 12

30. ping Command

Pings a host with audible feedback when it comes online.

ping -i 60 -a 8.8.8.8

31. tac Command

Outputs the content of a file in reverse order.

tac file.txt

32. strace Command

Debugging tool to trace system calls.

strace ls

33. disown Command

Runs a command in the background even after the terminal is closed.

sleep 1000 &
disown -a && exit

34. getconf Command

Displays the system architecture (32-bit or 64-bit).

getconf LONG_BIT

35. while Command

Displays the date and time at the top-right corner of the terminal.

while sleep 1; do tput sc; tput cup 0 $(($(tput cols)-29)); date; tput rc; done &

36. convert Command

Converts the output of a command into an image.

convert input.jpg output.png

37. watch Command

Displays an animated digital clock in the terminal.

watch -t -n1 "date +%T|figlet"

38. host and dig Commands

DNS lookup utilities.

host google.com
dig google.com

39. dstat Command

Generates real-time system resource statistics.

dstat

40. bind Command

Displays all Bash key bindings.

bind -p

41. touch Command

Forces a file system check on the next reboot.

sudo touch /forcefsck

42. lsb_release Command

Prints Linux distribution information.

lsb_release -a

43. nc Command

Checks if a specific port is open.

nc -zv localhost 22

44. curl ipinfo.io

Outputs geographical information about an IP address.

curl ipinfo.io

45. find Command

Lists all files owned by the user xyz.

find . -user xyz

46. apt Command

Installs all build dependencies for a package.

sudo apt build-dep vim

47. lsof Command

This command lists all services or processes that are currently listening on TCP port 80.

lsof -iTCP:80 -sTCP:LISTEN

48. find -size +100M

This command searches for all files and folders that are larger than 100 megabytes in the current directory and its subdirectories.

find . -size +100M

49. pdftk Command

pdftk is a powerful command-line tool that allows you to manipulate PDF files, including merging multiple PDF files into one.

pdftk file1.pdf file2.pdf cat output combined.pdf

50. ps -LF -u user_name

This command displays all processes and threads for a specified user, including detailed information about each thread’s status.

ps -LF -u john

51. startx — :1

This command starts a new X session on display :1, which is useful for running multiple graphical user interfaces simultaneously on different screens.

startx -- :1

That’s all for now! Don’t forget to share your thoughts in the comment section. This isn’t the end of lesser-known Linux commands; we’ll continue bringing more to you in our upcoming articles.

I’ll be back soon with another interesting and useful piece for our readers. Until then, stay tuned and connected to Tecmint.com!

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

44 Comments

Leave a Reply
  1. Hi Everyone,

    If you had problem in “loop login” after execute “startx

    use:

    mv .Xauthority .Xauthority.bak
    in tty1 (ctrl+alt+F1)
    

    thanks tecmint <3 .)

    Reply
  2. Hello Ravi,

    I have Linux server of 64 cores. 32 and 32 core each and connected. Whenever I submit a simulation job for 32 CPUs, so everything is fine. I track its process use. It shows in each line each CPU using 100~99%, and at the 3rd line %CPU=49.5. but when I submit more jobs (previous 32) + 24 CPUs, I guess it goes to the same node, and reduce the performance of the simulation.

    I checked using top command. it shows in first 2-3 lines, %CPU=49.5, but there are now 54 CPUs are running with 100~99% utilization. So, my question is that what command should I type to know whether there are 2 nodes or different devices in my Linux server.

    When I type the command iostat, it shows following output:

    Linux3.10 (Redhatsrv) -x86_64 (64 CPU)
    
    avg-cpu    %user     %nice   %system    %iowait     %idle
                     46.72       0.51     0.50           0.0             52.27
    Device:     tps      kB_read/s   kB_wrtn/s    kB_read      kb_wrtn   
    sda           4.69     1.41            79.83            969225      5493
    sdb           1.23   68.00          160.22        46795308
    

    If there are 2 device sda and sdb, then how can I submit job to sdb device, Give your expert opinion.

    Reply
  3. Python -m SimpleHTTPServer is deprecated and python2 specific

    python is normally linked to python3, so you need.

    # python -m http.server  
    or
    # python3 -m http.server
    
    Reply
  4. On your `nc -ZV` example, do you rather mean `nc -z` (or possibly `nc -zv`)?

    And for Pv — are you referring to pv (aka pipe viewer) or literally Pv?

    Reply
  5. On bash 4.1.2, I’m not seeing that a space before a bash command omits that command from history. Can you please elaborate on your explanation?

    Reply
    • Include this line:

      export HISTCONTROL=ignorespace;
      

      In /etc/profile or write it directly at the command prompt

      If the variable HISTCONTROL includes value “ignorespace“, lines which begin with a space character are not saved in the history list.

      Reply
  6. Regarding the first command, you can try “sudo!!” a thousand times, it does not work. I looked it up, and it’s “sudo !!” (with a space).

    Reply
  7. In the bottom page(footer) , there is a line with blue bar “Preparation for the LFCS (Linux Fundation Certified SysAdmin) Exam ” can see that the word “Fundation ” is miss spelled. this is just suggestion

    Reply
  8. Holy nice! some really useful and quite a few I don’t know yet. COol :)

    Note the `python -m SimpleHTTPServer` needs python2.

    Reply
  9. hello,
    i am new to linux i am having a problem with some of these commands dont work even if i have entered them right please help

    Reply
    • @Abhijit,

      Could you share with us what problem you facing while executing these commands? some of commands needs to installed before executing them, you can install them using yum or apt package manager tool as per your distribution..

      Reply
  10. I found this very interesting, along with the other lists on this site. Thanks, for putting them together.
    However, I found several typos including misspelled words. If you are interested I will detail them. Here’s a few.
    In the first paragraph “Linux user” should be “Linux users”. Down through text commas are used improperly to break up the text.

    Reply
  11. I am getting an error when I run the following:

    Command: curl -u gmail_id –silent “https://mail.google.com/mail/feed/atom” | perl -ne ‘print “\t” if //; print “$2\n” if /(.*)/;’
    Response: bash: syntax error near unexpected token `(‘

    Running Ubuntu 15.04.

    Any idea what the problem could be?

    Reply
    • Try the following command and don’t forget to add actual email also the quotes needed to be fixed..

      # curl -u [email protected]  -silent “https://mail.google.com/mail/feed/atom” | perl -ne 'print "\t" ; print "$2\n" if /(.*)/;'
      

      curl will need to have SSL enabled.

      Reply
  12. hi sir
    it is one of the best Linux site i have ever seen this is very use full for who want learn Linux
    sir i need your help to improve my knowledge on Linux i have done RHCE & RHCSA certifications but i did’t get enough confidence please tell how to prepare for interview and what are concepts are important

    Reply
  13. Great work Avishek- they are very helpful. I’ve been working on unix for several years but didn’t know some of the above commands

    thanks,

    Reply
  14. Hi., im from malaysia & im running fed19,
    [root@my-fedora cappingpong]# yum update
    Loaded plugins: axelget, fastestmirror, filter-data, keys, langpacks, local,
    : priorities, refresh-packagekit, remove-with-leaves, show-leaves
    adobe-linux-i386 | 951 B 00:00
    fedora/19/i386/metalink | 9.3 kB 00:00
    fedora | 4.2 kB 00:00
    fedora-HandBrake-source | 2.9 kB 00:00
    fedora-chromium-stable | 3.4 kB 00:00
    fedora-source/19/i386/metalink | 8.4 kB 00:00
    fedora-source | 3.1 kB 00:00
    home_darkhado | 1.6 kB 00:00
    Could not retrieve mirrorlist http://rpm.livna.org/mirrorlist-debug error was
    14: HTTP Error 404 – Not Found

    One of the configured repositories failed (Unknown),
    and yum doesn’t have enough cached data to continue. At this point the only
    safe thing yum can do is fail. There are a few ways to work “fix” this:

    1. Contact the upstream for the repository and get them to fix the problem.

    2. Reconfigure the baseurl/etc. for the repository, to point to a working
    upstream. This is most often useful if you are using a newer
    distribution release than is supported by the repository (and the
    packages for the previous distribution release still work).

    3. Disable the repository, so yum won’t use it by default. Yum will then
    just ignore the repository until you permanently enable it again or use
    –enablerepo for temporary usage:

    yum-config-manager –disable

    4. Configure the failing repository to be skipped, if it is unavailable.
    Note that yum will try to contact the repo. when it runs most commands,
    so will have to try and fail each time (and thus. yum will be be much
    slower). If it is a very temporary problem though, this is often a nice
    compromise:

    yum-config-manager –save –setopt=.skip_if_unavailable=true

    Cannot find a valid baseurl for repo: livna-debuginfo
    please help me!!

    Reply
  15. I have been using UNIX for 35 years and I did not know a few of those. Great work. Be careful of the capitalisation though e.g. Touch, Mount etc

    Reply
    • Thanks @ Dave Rea, for the nice feedback. Sorry for that capitalization, actually most of the word processor automatically does this. Requesting admin to modify.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.