10 Linux Commands You Probably Don’t Use

If you are a hard core systems administrator or Linux engineer you’ll probably recognize most of these Linux command line tricks. The following Linux command line tips are not typically used by your everyday Linux user.

Quickly Find a PID with pgrep

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.

pgrep ssh

This will list all PIDs associated with the ssh process.

Execute The Last Executed Command

The heading sounds a bit confusing but it’s exactly what it does.


This will execute the last command you used on the command line.

Execute The Last Command Starting With..

If you want to execute a command a command from history starting with the letter S you can use the following:


This will execute the last command used on the command line that started with s.

Run a Command Repeatedly and Display the Output

watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds. watch is very similar to tail.

watch -d ls -l

This will watch the current directory for any file changes and highlight the change when it occurs.

Save Quickly in VI/VIM

If you’re in a hurry, you can save and quit the file you’re editing in vi by exiting insert mode, holding shift, and hitting z twice.

Quickly Log Out of a Terminal

You can quickly log out of a terminal session by using: CTRL+D

Navigate to the Last Directory You Were In

cd - will take you to the last directory you were in.

Make Parent Directories the Smart Way

mkdir -p /home/adam/make/all/of/these/directories/ will create all directories as needed even if they do not exist. Why waste time doing something silly like: mkdir make ; cd make ; mkdir all ; cd all ; mkdir of ; cd of … you get the point. Use mkdir -p!

Delete the Entire Line

If you’ve just typed a long string of commands that you don’t need to enter anymore, delete the entire line by using: CTRL+U.

Set the Time stamp of a File

touch -c -t 0801010800 filename.c will show the time stamp as 2008-01-01 8:00. The format is (YYMMDDhhmm).

Can you think of any other Linux commands that are less known to the general Linux community?

Subscribe to my RSS feed here.

30 thoughts on “10 Linux Commands You Probably Don’t Use

  1. You can use the last argument from the last command by refering to it as $_

    so you only need to type a long path like this once:

    cp assignment.htm /home/phill/reports/2008/

    and do:

    cd $_

    to go straight to the 2008 folder as well. You can use this however you like. Always the last argument of the command above.

  2. I find it horribly saddening that people are falling away from the command line. I personally use most of these commands multiple times a day. To think that these are the ones that people don’t use…

  3. Pingback: 10 Linux Commands You Probably Don’t Use « Great Ideas in Teaching

  4. Pingback: Kiko Web Blog » Blog Archive » Article: Alcuni comandi UNIX poco conosciuti

  5. philluminati mentioned using $_ for the last argument of the last command; you can also hit Alt+. to quickly paste it at the cursor.

  6. I almost find this article’s title offensive. I too use most of these commands daily because my job requires I be efficient. Put it this way, its much easier to click on the wrong icon then it is to type the wrong program name. How often do you type “firefox” when you really wanted to type “xterm”?

  7. Should have mentioned using touch to make a new empty file – just the thing for new kids playing around. And speaking of things most users don’t use, how about linx and wget? Massive time savers, plus you can surf the web and download stuff without it being obvious to anyone who may wander past. ;o)

  8. In all fairness, I don’t see how you can categorize any of these as really being “Linux” commands. Hell, most aren’t really OS commands, per se.

    The only ones that are really OS commands would be the pgrep, mkdir and touch. Of those, the only one that’s even remotely specifically a Linux command is `pgrep`. Even that’s kind of a stretch, as several other *N*X’s have a pgrep implementation. Every *N*X implements mkdir and touch in the ways described above.

    The rest are “shell built-ins” – specifically, Bash. If you’re one of the (admittedly rare) users that changes their shell, your “Linux commands” likely won’t work (e.g., if someone installs and uses pdksh). While Bash was initially unique to Linux, the functionalities that you’re describing are functionalities that Bash borrowed from other shells (e.g., Tenex C-Shell). So, again: not really “Linux commands”.

  9. You are not quite right about ctrl-u. It doesn’t delete the entire line, it deletes everything to the left of the cursor. So it will only delete the entire line when the cursor is at the end of the line. Also, hitting ctrl-k will delete everything to the right of the cursor.

  10. One cool one I recently learned is fc, fc will open the last command from your shell history in the default editor. You can also specify a text editor. You can add a history line number or the first few letters of the most recent command. For example “fc -e kate wget” will open kate with the last shell command starting with wget. You can edit the command, and when you save and close kate, the command will execute.

  11. Oshu is right about ctrl+u; it only deletes everything to the left of the cursor. This is especially useful when you know you fat fingered your password and you want to quickly start over. Also works on cisco routers.

  12. The !! command is very useful when you forget to start a commando with “sudo” in Ubuntu:

    apt-get update
    sudo !!

    And yes, it looks like you are shouting: “I MEANT TO USE SUDO!” ;)

  13. Another useful command is ‘&’ (ampersand)
    Ending a command with ‘&’ runs the command with a new PID, releasing the command line back to you. Useful for running a background process.

  14. The one command *nix DOESN’T have but NEEDS:

    mkdir “$1″
    cd “$1″

    Save the above as an executable script (I call mine mkcd) and use it:

    $ mkcd dir

    Stupid, you say? I thought so, and now I get ticked whenever I’m on someone else’s system that DOESN’T have it. How many times to you end up having to make a directory and then immediately cd into it? Quite a few, if you’re like me. I know the above doesn’t have any error checking, but it’s for my own use. I have a similar script that acts like mv, only it makes a directory, moves the file into it, and then cds you into that directory.

    If there are other ways of doing these things, I’m open to ideas…….

  15. I think cd with no arguments takes you to your home directory on most systems (equivalent to cd ~), not last directory you where in as stated here.

  16. I never knew about +z+z in vi before. I suppose its just as many kepresses as exiting insert mode and typing : w

  17. Here’s a little-known but extremely useful one:

    Sometimes your terminal gets borked, for whatever reason. It gets put into a different display mode, it stops printing typed characters, it won’t display line feeds, etc. Instead of killing and re-starting your terminal session, you can merely type the command ‘reset’. This will reset your terminal back to its defaults, clear the screen, and everything will be as it was before.

  18. Slightcrazed, about your mkcd script i use mkdir dir && cd dir

    the second command execute only if the frist execute ok

    just like
    sudo aptitude update && sudo aptitude safe-upgreade

  19. Pingback: 10 Comandos de linux que tal ves no utilizas

  20. I cant say i never used all these command.
    i might not use everyone every day, but it almost pisses me off all these elitist users who have to post to this blog and point out that it is a useless post because _they_ know everything about these commands so everyone else should know them. have you ever stopped to think about that the linux platform gathers new users every day, and that these users need sources to learn things?


  21. When the title says “10 Linux Commands You Probably Don’t Use” I think what’s meant is ones you probably don’t know. Previous comments seem to suggest they think it means you would use a GUI for them instead of a command.

  22. Pingback: 10 comandos de Linux que tal vez no usas

  23. I don’t use the command line much (I am one of those relatively new linux users), but I did learn something from this post and the comments.

    @Ricardo Figueroa:
    Couldn’t you use {mkdir dir && cd $_} instead of {mkdir dir && cd dir} so as to avoid having to re-type the directory name — which you could possibly mis-type the second time?

  24. Actually, I never knew most of these tips, I use CLI often… thx bud

    You can save and exit vi by :x …. easier than shift+w+w

  25. If you are in a terminal, and you use a command, it occupies the terminal:
    gedit somefile
    If you use & at the end of the command, you can run the program and use the terminal in the same time:
    gedit somefile&
    If you forget to put & on the end of the command, and you would like to use the terminal without closing the application, press:
    The job stopped. You will see something like this:
    [1]+ Stopped gedit somefile
    Where 1 is the job specifier.
    After that you can start the job with:
    fg 1
    and your terminal will be reserved again. Or you can use:
    bg 1
    and your program and the terminal will be available in the same time.

  26. What about the built in ps and grep? Surely it’s better to know how to use grep with other commands… ps -ax |grep fox

  27. With Ctrl+e you wil go the end of the line. thats easy if you for example typed the following :

    # xd /home/testuser/somedir

    you see there’s a typo ( xd instead of cd ) to easyly fix this with out starting over again ( ctrl+c ), press ctrl+a which will take the cursor to the beginning of the line to make your change ( xd to cd ).
    then go to the end of the line with ctrl+e.
    and lets say you changed your mind about going to the dir in the testuser’s homedir. lets say you wantes to go to /usr/src instead.
    You can use ctrl+w to delete the argument backwards from the point where the cursor is.
    so in our example you pressed ctrl+e to go to the and of the line. now ctrl+w will delete “/home/testuser/somedir” so you can replace it with /usr/src ( using TAB to speed it up )

    so how to be really fast with this combined with your command history? here’s an example:

    # mkdir /tmp/foo
    # cp ~/somefile [esc-.]
    esc-. will return the last argument of the previous commando, same as alt-.
    ctrl+r and type ‘mk’ that will bring up the last command wich contains ‘mk’ in this case our last mkdir commando
    # mkdir /tmp/foo [ ctrl+w ]
    ctrl+w will remove the /tmp/foo
    # mkdir /usr/src/bar
    # cd [esc-.]

    these are short examples. most of the time when you have long oneliners you don’t want to type the all over or wait for the cursor to get the the beginning of the line.

    keep in mind that these are bash shortcuts. i dont know which will but as far as i know most will not work in an other shell like sh, ksh or csh

    read man bash if you want to know more to be faster and more efficient



  28. One of my favourites is still pushd and popd; these are used to push items (such as the current directory) on or off the of stack.

    [/home/username] # pushd .
    [/home/username] # cd /usr/bin
    [/usr/bin] # popd
    [/home/username] #

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>