Linux Commands

 

*To login as root in the terminal type su and then enter your root password and then press enter again - this will allow you to install programs that can't be done in regular user mode sometimes. Don't forget this!!!

Note: Get used to using these, write them down, bookmark this site, but you should always have access to these commands...

Also VERY IMPORTANT: when you are installing source files (tar.gz) and you extract them, you need to do so in a directory that is very simple. Linux doesn't appear to like it very much when you try to install a source file from a directory with spaces, capitals or other symbols in it. The source file needs to be able to enter the directory where the source file is very smoothly and cleanly. A good example is to use /home/usr to put your source files in. You can easily delete what is left over after they are installed. This prevents you from getting errors saying that the compiler could not leave and re-enter the directory where the install file is.

All of these commands need to be entered in the terminal unless otherwise stated. Try them as user first, only use root if you have to.

When you see [filename], substitute the full name of the file. If you type the first few letters of the file and then press Tab, it will usually autocomplete the name of the file which saves a lot of tedious typing sometimes.

Compressed Files

.tar files = tar -xvf [filename]

.tgz files = tar -xzvf [filename] (or right click and select "extract here" - in either case it creates a folder from the original file)

.bz2 files = bzip -d [filename] OR bunzip2 -d [filename] (these files can be picky, so use whatever works. Someone else recommended using "tar xvjpf")

*Once any of these files are unzipped/uncompressed, they should create a new folder by the same name. You need to go into that folder's directory for any of your terminal commands to work - very important!

Next - go into the appropriate folder and to install....

use the terminal and type in this order all of these commands

./configure (this configures the files within the folder, you will see lots of writing on the screen scrolling. Make sure you read the last few lines to make sure it doesn't report any errors)
note - if there are errors reported you can check them by typing ./configure errors

make (prepares the files for a full install)

you might need to be root to do the following command, in the terminal , you can type: su, then enter then your root password, then try the following commands again.

make install OR make all install

make uninstall [filename] - uninstall a source (tar.gz) file


RPM's

A lot of new users like these types of files because they are probably the easiest to use. They are installers and often you can install them by right-clicking on the file and then selecting "Install" From there you just wait till it's done. If you want to use the terminal then it is best to use konqueror file browser (not web browser) to go to the directory where the file is and then select (at the top menu) Tools-Open Terminal and then enter your rpm command from there. Don't forget that you can use tab key to autocomplete the names of the files that you are installing so you don't have to type the whole thing out. Here are some commands that are associated with Rpm files:

rpm -ivh [filename] (installs a package)

rpm -?vh [filename]--test (tests a package but doesn't install it)

rpm -Uvh [filename] (upgrades a package to a newer version)

Tricks I have learned:

To install a series of rpms all in one directory with no other files in it:
rpm -ivh *

To install a series of rpms all in one directory with other file types in it:
rpm -ivh *.rpm

rpm -e [filename] (uninstalls package - use with caution)

rpm --help (self explanatory... hopefully)

RPM.BIN a few lines needed for these, do all of the following in the terminal...

chmod a+x [filename]

./[filename] (in the directory where the file is located)

.BIN

./[filename] (in the directory where the file is located)

.run

sh [filename]



Other Commands you can Enter in the Terminal:


/sbin/lsmod (lists all the devices attached and recognized by linux)

/sbin/ifconfig (lists your internet information - should have two sections: eth0 and lo for high speed for example)
top (lists processes)

/sbin/lspci (lists all pci devices connected and recognized)
cdrecord -scanbus (lists cd rom devices that have scsi enabled - your cd burner should be here if you have one)

rpm -qa|grep [filename] - (where as the "|" is the "\" key shifted) to find out what packages and versions are installed associated with a certain program. Command used in rpm based distros only.

ps -e - lists the processes that are running currently on your system

free - shows the amount of system memory used by your system, swap and cached.

/sbin/ifconfig - shows properties of your network

/sbin/ip addr - displays your internet address
/sbin/ip for more options

mkdir - makes a directory (ie- mkdir ctmlinux)

rmdir - removes a directory, but only if it's empty (ie - rmdir ctmlinux)

rm -r - removes a directory even if files are within (ie - rm -r ctmlinux)

rm -rf - same as above but the 'f' will force it if it isn't working for some reason.

rm -ir - removes a directory but prompts you to ok the deletion of each individual file within (ie - rm -ir ctmlinux)

aumix -I - as long as aumix is installed, you can use that command in your terminal to get an interactive display of your volume levels that allows you to adjust it. This is handy if you don't have kde or gnome or don't use a window manager and only use text mode. For more info, you can see the aumix man page (leaves a lot to be desired imho though).

-v - displays the output in the terminal. This is helping for cdburning (cdrecord -v...), copying and moving files (cp -v or mv -v respectively)

mkisofs -J -r -o [filename].iso /mnt/cd - Makes an iso of whatever information it sees mounted in the cdrom drive (your mountpoint may be different than /mnt/cd)

useradd -m -s /bin/bash [username] - Adds a user to your box and copies a skeleton directory, creating a /home for that user.

groupadd [groupname] - adds a group of whatever you select - check your /etc/group file to make sure your user is able to use that group

userdel -r [username] - Deletes the selected user.

tar -czvf [filename].tar.gz [directoryname] - Creates a tar.gz file from the specified directory.

tar -czvf [filename].tar.gz [filename1] [filename2] [filename3] (and so on) - Creates a tar.gz file from the specified files.

To View the files and filesize or files on one's computer:
du -h [directory or file]
so for root:
du -h /
to slow it down so you can scroll thru it:
du -h / |less
To list directories by filesize:
du /* -s -h
(for root)

Creating an alias


Basically it means to create short forms for some of the commands you use in the terminal or you can change what things are called to make more sense if you like. Here are a couple of examples:

For cdburning: blanking a disc: alias blankcd="cdrecord -v speed=12 dev=0,0,0 -eject blank=fast"
(this means you only need to type in "blankcd" (no quotes) in order to erase a disc.
For seeing what is in a directory: alias dir="ls -a"
(if dir makes more sense to you than ls -a, then you can use that to view the contents of a directory.

*note - you only need to use the quotes when there are spaces in the command for which you are creating the alias, so if you only wanted to use "ls" in the second example instead of "ls -a" you could do this: alias dir=ls and that would work as well.