20 Useful, Common Linux (Ubuntu) Commands for New Users 06/20/09

I recently was asked by a new Ubuntu user (also involved in web, graphic design, etc.), what some of the more common day to day commands I use are.

Many of these commands can increase productivity, etc. by making things (for me at least), easier to do. My system desktop has a transparent terminal integrated into it. This makes it easy for me to run commands as I never have to open a terminal – my desktop in effect, is the terminal.

These are useful commands! Ones that will actually help you do something! Other more common commands (chmod, chown, ls, cd, etc.) can be found elsewhere on the Internet. I tried to stay away from such basic commands, unless they were really useful (like rebooting).

Hopefully, the following will help out some of my readers. If you’ve some good commands, feel free to comment!

1) To find out the processes running that use the most memory. When things are running slower than I want, and am looking for which processes I can kill:

ps aux | sort -nrk 4 | head

2) To see the version of the installed package, when I’m considering an application upgrade:

apt-cache policy xxxxxx (where xxxxxx is the name of the package).

3) To mount an ISO image, so that I don’t have to burn it if I don’t want the ISO after review:

mount /xxx/image-file.iso /mnt/cdrom -o loop (where xxx is the path).

4) Find out where that newly installed package went. This happens to me a lot… I just installed it, where did it go?

whereis xxxxxx (where xxxxxx is the package name).

5) Ever reinstalled an app to find the old configuration still working? This will purge the config files of Ubuntu packages:

sudo aptitude purge `dpkg –get-selections | grep deinstall | awk ‘{print $1}’`

6) Go back and look at the commands I ran, when I’m to lazy:


7) Remove a .deb package (obviously not installed via aptitude), this way I was not afraid to download and use .deb files if the package was not available within Ubuntu or launchpad repositories:

sudo dpkg -r xxxxxx (where xxxxxx is the name of the package).

8) Create an image (.iso) of a CD or DVD – For me this is the easiest:

mkisofs -r -o xxxxxx.iso /cdrom/ (where xxxxxx is the name for the file).

9) Make a backup of a file before editing (such as sources.list). I learned the hard way, ALWAYS backup a file (that’s a .bak file for me) before making changes to it:

sudo cp /xxxxxx/sources.list /xxxxxx/sources.list.bak

10) Add (append) entry to sources.list – For me it’s a simple easy way to do this than clicking my way through the GUI:

sudo echo “xxxxxx” >> /etc/apt/sources.list (where xxxxxx is the address you want to add).

11) Erase a re-writable CD (CDRW), for me at least, musch faster than using a GUI:

cdrecord -v dev=/dev/cdrom blank=fast

12) Reboot a system or server, when I’m installing or making changes via SSH, that require a reboot:

sudo shutdown -r now

13) Get a fast text list (called “installed-packages”) of what’s installed on my system:

dpkg –get-selections > installed-packages

14) Simple way to kill a process, I’m too often lazy to find the process ID:

killall xxxxxx (where xxxxxx is the name of the process)

15) Quickly remove downloaded package manager updates, when no longer needed:

sudo aptitude autoclean

16) Easily add a downloaded key to the repository sources (for aptitude/apt-get):

sudo apt-key add xxxxxx.gpg (where xxxxxx is the name of the key file).

17) Force CD to eject the disk:

sudo umount /media/cdrom0/ -l

18) Security… leave the terminal open, but remove sudo passwords so there are no “issues”:

sudo -k

19) Sometimes I need to change a bit of text in several files. Instead of opening each one to edit, I do this instead:

grep -lr -e ‘xxxxxx’ * | xargs sed -i ‘s/xxxxxx/yyyyyy/g’

Note: xxxxxx is the word you want to change (replace) and yyyyyy is the new word you want used.

20) Fast way to convert .ps (postscript – print to file format) to PDF:

ps2pdf xxxxxx.ps xxxxxx.pdf (where xxxxxx is the name of the file).

Don’t have the command ps2pdf? sudo aptitude install ghostscript or apt:ghostscript

As usual, I hope some of these help someone – Let me know! Don’t forget to add your comments below.

Care to Share?

You can leave a response, or trackback from your own site.

8 Responses to this article

BigWhale June 20, 2009 Reply

I’d add three more:

21) Finding (case insensitive) files or directories:

find /relative/path -iname "filename"

22) Checking which executable file you’re actually running:

which filename

23) Deleting all filenames (and only files, not directories) with the same name anywhere on your drives (careful with this one)

find /realtive/path -type f -name "filename" -exec rm {} ;


Steven June 20, 2009 Reply

alias ll='ls -l'
#(might want to stick that in your ~/.bashrc file)

#to find out where you are

#useful if you’re on a server and switch users a lot

#and of course…..
#never again will you have to face RTFM ;)

Jady L. June 23, 2009 Reply

ffmpeg -i input.flv -f mp3 -vn -acodec copy ouput.mp3

sudo sysctl vm.swappiness=0
sudo swapoff -a

Sephi June 28, 2009 Reply

10) A shorter way :
sudo cp /xxxxxx/sources.list{,.bak}

12) A shorter way :
sudo halt

17) An easier way which doesn’t require root privileges (don’t know if it works if the drive is busy) :

Dan the ubuntu Man January 11, 2011 Reply

These were helpful! I dropped them into my anki deck for memorization.

Other ones I’ve found useful…

man -k KEYWORD

Searches man pages for a keyword within any given entry.

Ctrl+r searches previous commandline history rapidly.

I particularly liked your one on copying down CD’s as iso files from the commandline. Would love to know how to burn an iso from the commandline as well.

jail February 10, 2012 Reply

same here dan
i wish i could just run thru command all the time and strickly use my graphics for such things that require them .. FB … and such

jail February 10, 2012 Reply

im just getting started… i know a few commands and love my ubuntu 10.4 .. I learn something new everyday.. love it great os and any terminal commands would greatly help out … I really try to avoid GuI if possible

jail February 10, 2012 Reply

I tend to use alot of sudo commands and very few others…… Feedback would be much appreciated.

Leave a Reply

close comment popup

Leave A Reply