A Quick Guide to UNIX |
For those of you with little knowledge of UNIX, this page will familiarize you with the most basic Unix commands that you need to know. Linux is a flavor of Unix, so users of Linux will find this page helpful, too. Another useful link is at http://engr/uark/edu/info/help.
First off, when you log in to a Unix machine such as engr.uark.edu, or a Linux machine such as csce.uark.edu, a shell is started, just for you. You do all of your work in this shell. These are the most basic commands and programs that you'll be using in the shell:
| ls | to list a directory (use ls -l to see everything in your directory) |
| rm filename | to delete a file (use rm -r to remove a directory and everything in it -- carefully!!) |
| more filename | to see a file one screen at a time (use ls -l | more
to view directory one screen at a time) |
| man command | to access help on a command |
| cd subdirectory | change from the current directory to the subdirectory |
| cd ~username | change from the current directory to the root of another user's directory |
| pine | Mail program |
| pico | a simple text editor (if you already use vi or emacs, that's fine) |
| vi | a more robust text editor. A quick reference sheet for vi and Unix is available. |
Unix is case-sensitive, so you'll have to type lowercase
for most commands, and use the correct case for all filenames.
A hint to make your life easier, in order to prevent
information from scrolling by at the speed of light, type:
whatever your command is | more
This way, you can read information one screenful at a time
(and not pull your hair out!).
Dot files are files that start with a dot, like .cshrc, .login, .pinerc, .tinrc, and so on. These files are not usually seen when you type ls; rather, to list everything in your directory, you need to type ls -a (for list all).
Dot files like .tcshrc, .cshrc, and .login are accessed when you first log in. They help configure your shell account.
For more information on dot files, look at this quick guide to dot files. It also has a link to information on aliases, which you may also want to learn about, for your convenience.
You can use a text editor like pico to look at your dot files. Before you tinker with dot files, make a backup copy by using the cp command. For example,
cp .cshrc .cshrc-backup
will make a copy of .cshrc and name it .cshrc-backup. If you goof and want to use the original file again,
cp .cshrc-backup .cshrc
When you take a closer look at your directory, you find lots of
rwx---r-x items floating around. Just what does all of that mean?
Keeping track of your file permissions are important -- after
all, you don't want just anyone to look at your work!
![]()
First, you probably want to know what the letters r,w,x stand for.
Then, you have to look at the groups of letters after the d (or - if it's just a file).
![]()
The user is you, and the world is everyone. But what is a group? That is usually defined by your system administrator. For example, depending on the machine that you are logged in to, there may be a group for all undergraduates, a group for the CSCE department faculty, a group of EE grad students, etc.
So how do you acutally change permissions? Try
chmod is used to change the permission of a file. The basic syntax is:
chmod mode file
So, for example, say you have a file like this:
-rw-rw-r-- 1 k-garner exec 1319 Sep 17 18:12 permissions.html
You decide that you no longer want the group exec to be messing up your file:
chmod 644 permissions.html
Now the file looks like this:
-rw-r--r-- 1 k-garner exec 1319 Sep 17 18:12 permissions.html
So now you can read and write, and everyone else can just look at it (and weep).
700 drwx------ Owner everything, Nothing for everyone else 755 drwxr-xr-x Owner everything, Others just read 711 drwx--x--x Owner everything, Others can only cd into dir 600 -rw------- Owner everything, Nothing for others 644 -rw-r--r-- Owner everything, Others can read 755 -rwxr-xr-x Owner everything, Other can read and execute
Cool trick: If you know your binary, you can figure out the numbers on your own. rwx is 7, rw- is 6, r-- is 4, and --- is 0.
Pay attention when you change permissions on a file
or directory. It is possible to set the permissions so that
even you don't have read or write access to your own file!
(If you ever do this, you can set the permissions back as long
as you own the file.)