Note: You are viewing an old revision of this page. View the current version.
  • The Linux equivalent of MicrosoftWindows' ipconfig command is ifconfig(8).
  • Global system configuration files are in the /etc directory.
  • Under Debian-based distributions (such as Debian Sarge, Ubuntu, etc):

    • Install Deb Packages using dpkg -i filename. See dpkg(8).
    • To search for packages available on your distribution, use aptitude search name
    • To install a package, and any other packages it depends on, use aptitude install name
    • Note that names are case insensitive, and contain no spaces. Try doing a substring search if you can't find it at first. Debian has over 15000 packages, so there is a good chance it already has what you want.
  • Under RedHat-based distributions:

    • Install RPM Packages using rpm -Uvh filename. See rpm(8).
    • RedHat based systems now offer better PackageManagementTools? such as AptForRpm or Yum. Use them instead of manually finding .rpms and installing them
  • Use tar xzvf filename to decompress a .tar.gz or .tgz file, otherwise known as a TarBall. See tar(1)
  • Use tar xjvf filename to decompress a .tar.bz2 also known as a TarBall. See tar(1)
  • Don't get involved in emacs(1) vs. vi(1) arguments. Use nano(1), pico(1), joe(1), or jed(1) for your initial editing needs. Once you have gotten a little more comfortable with the system, however, be sure to revisit emacs(1) and vi(1) as they offer tons of power you will never get with the simple minded editors. For the latter, Vim is the suggested clone, which comes with a vimtutor program that should get your over the initial hurdles quickly. Does any equivalent for emacs(1) exist?
  • The cp(1) command copies files. The -a switch is for copying directories.
  • Before you ask for help online, be sure to read the documentation first. It is sometimes difficult to understand so don't feel bad if you don't get it, just make the attempt. It will either make any explanation you get from someone else clearer, or the explanation will help you understand the documentation. Next time you look at it, the documentation will be less puzzling. If you repeat this a couple times, then you'll soon be cruising along with the docs just fine.
  • If your desktop locks up, Ctrl-Alt-Backspace will kill the graphical environment (the XServer, in technical terms) and drop you to the Shell (or your display manager) without having to reboot the system.
  • You don't have to worry about defragmenting your disks.
  • You don't have to worry about defragmenting your memory.
  • You don't have to worry about mail Worms.
  • Linux will crash on you at some point. It happens, no matter what anybody says. However, it won't happen nearly as much as it does on MicrosoftWindows.
  • You don't have to shut down or restart every day. It's ok to leave a Linux system running for a week or more (some users have their system running for months at a time). You should still conserve electricity, tho.
  • There is no way to undelete a file in Linux. You deleted it, it's gone. See rm(1)
  • sudo(1) will let you execute a command with SuperUser (or any other) privileges; it may need to be configured, in that case, see SudoHowto. If you really need a root shell, you can use su(1): execute su - and type the root password. You should never log in as root (except if you managed to get the system so shot up that you can't log in as a user).
  • Installing a program from source is easier than you think. The sequence is usually along the lines of
    tar xvzf filename-version.tar.gz
    cd filename-version
    ./configure && make
    sudo make install

    Note you have to be root for the make install step if you are installing into system wide directories. You can always install to your home directory, of course -- which you need to indicate by saying ./configure --prefix=$HOME on the relevant step. You can also pass many more options, to configure, most of which needn't concern you, except for the (usually few) --enable-foo/--disable-foo and --with-bar/--without-bar which let you hand-pick features to include or omit from the resultant build of the software.

  • Make sure you are working on the correct drive when doing any FileSystem level work -- nuking the wrong partition or disk is annoying to say the least.
  • Learn how to use redirection ("<", ">") and pipes ("|") in the Shell. See bash(1)
  • Your initial WindowManager settings are (generally) stored in the .xinitrc or .xsession file in your home.

    • Note that this isn't so relevant any more with GNOME and KDE

Handy Ubuntu Tips

Write a bash script.

Open up your favourite text editor and add this line to the top:

  • #!/bin/bash

Now add your bash commands and at end of each line add a ";" Save you file and make sure you chmod to give execute permissions.

Extract zips that are in multiple parts.

*unzip -d destdir/ \*.zip

REMEMBER : The '\' is the escape character. Without it, our command would look like: unzip -d destdir/,, which is bad because after the first zip argument, the following stuff is read as list arguments. With \*.zip bash doesn't interpret the * but unzip does.

Extract rars that are in multiple parts (Using Rar Linux) (eg: .rar,.ro1,r02...)

  • unrar name.rar destdir/

Note: We only need to supply the file with the ".rar" extension. Rar is smart and detects the other files.

Cool tools to play around with

  • cal

Typing this command will display a calendar with the date highlighted.

  • date

Will display the date and time in terminal.

  • dmesg

Displays log of messages printed to the screen during the boot process

Where on Earth is the rename command?

We use the "mv" command when renaming instead.

  • mv dog cat

This will rename the file "dog" to "cat".

You can copy/move/list multiple things at a time! Just separate files/expressions with a space.

  • ls -l *.txt *.letter
  • cp *.jpg *.bmp ~/pics/

How to Stop listing dir contents when using glob expressions with ls.

Use the -d switch to list just the directories, and not the contents of each matching directory.

Change Password

Simply type "passwd". You will be prompted for the current password and then asked to type in a new password.

Jump quickly between words in terminal

  • Alt-f - Move forward one word.
  • Alt-b - Move backward one word.

Print to screen first/last few lines of a file.

  • head -n 20 test.txt

Will print to the screen the first 20 lines in test.txt

  • tail -n 5 test.txt

Will print to the screen the last 5 lines in test.txt

Print a Message To The Terminal

  • echo Damn you rock Staz

Note : Make sure to type the above exactly as it is written.

  • echo $PATH

Slightly more useful!

Display a long file to screen

  • more test.txt

Will print the first page of test.txt to the screen, and you can use arrow keys to navigate further.

  • less test.txt

A more advanced version of more. (Can do Searches etc).

Search command History

  • Alt-r

Now Start typing part of the command any matches will be displayed as you type and press enter to use them.

What type of file is that??

  • file <filename>

Will return the file type.

Reload fstab file

  • sudo mount -a

This mounts everything in your fstab file.

How much disk space is the contents of this directory using?

1)All Folders/Subfolders

  • du -h

2)The current directory

  • du -sh

3)All folders excluding subfolders.

  • du --max-depth=1 -h

4)All folders beginning with the letter P

  • du -sh P*

Mount Samba Shares

We need to get the smbfs and smbclient packages.

  • sudo aptitude install smbfs
  • sudo aptitude install smbclient

First lets get a list of the available shares on a particular machine.

  • smbclient -L <IP/HOST>

Now create a folder in /media/ that will be the mount point for your samba share. There are two ways of mounting: 1.

  • sudo smbmount //<IP/Hostname>/smbshare /media/mounthere/ -o username=YYYY,password=YYYY,dmask=XXX,fmask=XXX


  • sudo mount -t smbfs //<IP/Hostname>/smbshare /media/mounthere/ -o username=YYYY,password=YYYY,dmask=XXX,fmask=XXX

dmask = directory umask fmask = file umask

Now to unmount:

  • sudo umount/smbumount /media/diryoumountedto/

Add a smb share to fstab that is automatically mounted on boot

  • sudo /etc/fstab

Add this line: //HOST/share/ /mount/point/ smbfs auto,username=xxxxx,password=xxxxx,uid=xxxx This website is really good:

Mount all smb shares listed in fstab

  • sudo mount -at smbfs

Unmount all smb shares listed in fstab

  • sudo mount -at smbfs

List NTFS Mounted Drives

  • sudo mount -t ntfs

If you want to view mounted fat32 drives simply replace "ntfs" with "vfat"

How much memory is free?

  • free -m

Will tell you how much free memory is available in megabytes.

  • free -s 60

Will tell you how much free memory is available every 10 seconds.

List all your drives

  • sudo fdisk -l

NOTE : Don't forget the "sudo" or else you may not see anything listed. Blocks can be read to mean "Kilobytes"

List Drives/Capacity/Free Space

  • df -B M

The -B switch refers to Block Size. The M means it will be displayed in Megabytes. But if you prefer use K for kilobytes, G for gigabytes etc..

df(1) doesn't require root privileges to work. Also "df -h" will select the right units for you. Many programs that support outputting units will support "-h" for "human readable". The other useful command here is du(1).

Install an app from .rpm

First you need Alien: sudo aptitude install al

See also AdvancedUserTips