Below are the most useful commands (or at least those I found most helpful) when I switched to Ubuntu, to clarify, these commands are not Ubuntu specific, they are Debian Linux commands. I’ve not included some of the basic commands like cd, rm, mv, ls, etc… Play with your terminal, that’s a great way to spend a Friday afternoon! Hee hee hee… (Yes, I’m a geek!)
These commands are in no particular order, I just find they are the more helpful (for me and a few of the “converts” near me).
sudo
Execute each command as root, which is safer than actually switching into root via “su”.
ifconfig
Displays the network card connection/configuration.
sudo apt-get install PackageName
Will install the whatever “PackageName” I typed and the dependancy files.
sudo shutdown -h now
Shuts down my Ubuntu and powers it off right away.
&&
Command to complete more that one action. For example:
sudo make && make install
Which runs the “make” script and then installs the “made” package.
ping 10.0.1.1
Sends test packets to whatever IP you type in, to help troubleshoot network connections.
apt-get moo
Just to look smart!
Try it!
cat /etc/issue
Displays the current Ubuntu version.
wget http://syserr.com/stuff/madwifi-cvs-20051025.tar.gz
Will download the file from any URL you enter after “wget”
tar -zxfv madwifi-cvs-20051025.tar.gz
Will uncompress the downloaded file
z means “Gunzip(uncompress) it before extracting, used on file ending in .tar.gz or .tgz”
x means “Extract the contents of the TAR file”
f means “Filename to follow”
v means “Verbose - display contents as it is tarring or extracting”
chmod +x install.sh
Command that says “Make the script file install.sh executable”. I sometimes run into this after using wget and trying to run installer scripts.
sudo apt-get autoclean
Removes partial packages.
sudo cp /home/roger/backups/bk03072008.tar.gz /var/www/downloads
Copies a file from one directory to another directory. (in this case the file bk03072008.tar.gz was copied to the /var/www/downloads directory).
If you don’t want to copy but move the file, change cp to mv.
find . -name “*.odt”
When looking for OpenOffice documents (in the current directory and all it’s subdirectories) or find ./roger -name network_notes.odt when I know the exact name of the file.
..
Move up one level in the directory structure.
iwlist scan
Dislay wireless networks that are in range.
mkisofs -V LABEL -r dir | gzip > backups.iso.gz
Makes a CD image of the backup directory contents
cdrecord -v dev=/dev/cdrom blank=fast
Quick command to erase a CDRW
history -c
In a multiuser environment, it is sometimes not good to leave history. Of course you can just “exit” to leave the terminal.
arch
Displays the processor architecture so I know if I should download i386, i686 based application pakages.
whereis something
Displays where “something” is stored.
There are 100’s more. But these are the ones I tend to use more often. As usual, I hope this helps others!
And… one for the road…
If you want to create a file called “me”, just “touch me”


There are 23 comment(s) added so far...
“sudo shutdown -h now” can be shortened to simply “sudo halt” Also, I think you need a “cd” before that “..”
The z for .tar.gz’s and j for .tar.bz2’s are no longer necessary. Tar just kinda figures it out and does it automatically. “tar xf ….” works just fine on both.
&& isn’t exactly what you think it is either. To just list commands, use ; What && does is says “IF the command on the left completes successfully, THEN do the command on the right.” You can use || to say “IF the command on the left fails, THEN do the command on the right”
Oh, another way to get the distro version, which I’m pretty sure works cross-distro (/etc/issue isn’t on Fedora systems, I don’t think), is “lsb_release -a”
@Mackenzie - Thanks for the input! If make fails for some reason we would not want to && make install
Cheers!
to shutdown I use init 0…works on bsd & solaris too
also all the apt-get commands are only good on Debian based systems(which Ubuntu is). Fedora, Mandrivia or Suse will not be able to do anything apt related without customizing.
Very useful list, but…
>> these commands are not Ubuntu specific, they are Linux commands.
…apt commands are Debian specific.
@Ray - Yes that’s right. Remember, this is an Ubuntu based blog. And, Ubuntu is based on Debian… Hence the URL: UbuntuLinuxHelp.com;)
@Michael - Yes you are right. I added the word ‘Debian’, to clarify the post.
Thanks.
Also, I read with interest your blog post “DAS Festplattenproblem unter Ubuntu”. Is this still a problem, also in, Ubuntu 8.04? The fix (to edit the “/ etc / acpi / power.sh”) was well laid out too.
sudo is NOT safer than becoming root through su. It’s just more convenient, since you don’t need to know the root-password. Some distributions such as Ubuntu doesn’t even have the root-account enabled.
In fact, a lot of these things are either slightly incorrect or just plain incorrect.
@isecore - “sudo is not safer…”? It sure is safer, in my opinion! It prevents me from accidentally doing something wrong. If I leave myself in sudo su, I can accidentally do something wrong much quicker than I’d do by typing sudo. With sudo su anything can be done. There are some things you don’t necessarily want to do in root.
In other words sudo su gives me privileges on the entire server! (As it switches the user environment and privileges to root).
Whereas sudo allows me to run commands after being prompted for my normal user password, and if the root user has given me permission (in the sudoers file) to perform that action, then I will be able to do it.
If you found a command that is incorrect, it would be helpful to clarify.
Thanks.
Or you could just show shorter versions or explanations like ‘Mackenzie’ (above) did on one; which helps everyone.
Keep in mind that these commands work perfectly on my Ubuntu Linux 7.10 and 7.04 boxes.
Sudo when set up with correct permissions is in fact safer. The default *buntu install is generally not set up this way, sure there is no root password, but if someone gets the first users password, 99% of the time that gives them as much access as root anyway. The idea of sudo is to give certain users or groups access to certain commands without the full root access that you get as a default setup in ubuntu. IMO this gives many users a false sense of security, thinking they are safe just because root is disabled and they use sudo.
When I use arch I get a command not found message.
Using gutsy
@steve - It works at this end. I get ‘i686′…
It seems not everyone has it working if you check the Ubuntu forum here: http://ubuntuforums.org/showthread.php?t=597213
Also a note on using && Remember it stands for the logical operator AND. So when you say:
sudo make && make install
make install will ONLY run if ’sudo make’ executes properly (which is what you would want in this case)
you can also use || (logical OR) to complete the second task only if the first task fails
cd dirA || mkdir dirA
if dirA doesn’t exist, make it
the logical operators can be combined too
cd dirA || mkdir dirA && cd dirA
if dirA doesn’t exist make it, and if successfully made, change into it
to combine tasks, use a semi-colon. I.E.
mkdir dirA; cd dirA; wget http://…
(will make a new directory dirA, change into that directory and then download whatever is at http://… into the current directory, dirA)
cd dirA || mkdirA && cd dirA; mkdir dirB
this one is for you to figure out
@guitarman_usa: Ah ha!
So…
cd dirA || mkdirA && cd dirA; mkdir dirB
means:
Change to dirA OR make dirA (if we’re unable to change it) AND (if dirA is successfully made), change to dirA then make dirB (because of the combined task). dirB will be made inside dirA.
I get it! Cool!
Thanks for the input. Simple as it is, this is very good to add to backup scripts (as well as a couple other things).
Thanks
Cheers!
Just a quick note: They are trying to ween people off “apt-get” and instead suggest using “aptitude” as it is generally considered more complete and better at picking up dependencies…or something like that.
@Ghost|BOFH - Thanks for the input.
Question: Didn’t I read something via Digg a while back that pointed to a big post about the evils of Aptitude, and how they were recommending it not be installed? Or am I just mixing that up with something else?
Thanks…
to reboot you have a few ways.
“sudo init 6″ or “sudo reboot”
if you are at a true terminal (not in X) just hit ctrl+alt+del
to halt, “sudo halt” is sufficient
or you can do “sudo init 0″
The init commands call their respective runtimes.
0 = halt, 6 = reboot, and i think 5 is gui (per most preconfigured distros, can be changed on a “from scratch” system)
I know you all prolly know this, and correct where wrong, but just putting it out there for the beginners.
Look, the title of this post is “Useful Linux Terminal Commands for New Users” how is using init or even halt more intuitive to the new user than shutdown and reboot respectively? Also, I wonder why the author assumes that all new users would be using the apt package manager (not every new user jumps to ubuntu). Also, a couple of no brainers for a new user would be man, whatis, and locate. Anyway, I’m done ranting. Glad to see the effort out there to help new folks but I think some of us go a little over the top in what we think is something a newbie should know. The learning curve is fairly steep ( though thankfully now not nearly as steep as it used to be) and it’s all about the baby steps :). Cheers
**edit above post**heh woops jumped the gun. i got here via stumble and didn’t realize this was an ubuntu site. heh apologies to the author for jumping the gun on the apt comment.
@Travis - No worries.
Cheers! Thanks for the extra input and perspective.
Also, with Ubuntu 8.04 I understand the command should be “aptitude” in place of “apt-get”. I understand that aptitude removes unused dependencies when uninstalling an application, whereas apt-get does not. I did a quick google to confirm this and found a great blog post about the differences here: http://www.psychocats.net/ubuntu/aptitude
To previous commenters: I’ve been told that apt-get and aptitute have the same functionality since Ubuntu ~6.04.