Tuesday, February 26, 2008

Linux Commands

As you have discovered, Linux is somewhat different than Windows. The paths to files are much different, for example in Windows you have a path like:

C:\Documents and Settings\jlevy\My Documents


However in Linux, there are no drive letters and the slashes go a different direction:

/home/faculty/jlevy


Everything in the file system is mounted after the root directory, which is just a forward slash - /

We also learned that there are several users on the same Linux server and that each user has his/her own home directory (folder) that has the same name as the username. You can see above that I have my home directory with the same name as my username: jlevy. It is inside that folder that I have permission to create and use new files.

We also learned that when we log in, we can see who we are and which directory we are in by looking at the prompt:

[jlevy@cs12 ~]$

You can see my username and the tilde ~ which indicates that I am in my home directory. After you log in, the commandline is simply waiting there for you to issue it a command.

Basic Commands

In the last class we covered some basic Linux commands such as:

passwd changes your password

clear clears the screen
pwd print working directory
tree print out a tree of all
files from location

mkdir create (or make) a new directory
rmdir [directory] remove directory

rm [file] remove file
rm -Rf [dir] remove directory and all files
inside DANGEROUS!

touch [file] create (or update) a file

ls list out files
ls -a list out all files including
hidden files

ls -l list out files with permissions
ls -al list out all files with permissions

cd [path] change directory to [path]

cp [oldfile] [newfile] copy the oldfile to the newfile
or location

mv [oldfile] [newfile] move the oldfile to the newfile
or location

chmod [perms] [file] change the mode (permissions)
to perms for file

pico [file] open file for editing with pico
text editor

exit end session (logout)


One thing to note about Linux: Commands ARE case sensitive so you have to type them in all lower case!

No comments: