Unix Commands

You must first use the ssh command to log into linux.gl.umbc.edu. Please right click on Desktop then Open Terminal. At the Unix shell, type ssh linux.gl.umbc.edu. You may be prompted with a question. If that is the case, answer yes (type the actual word "yes"). Then type your password to login. When you first login to your account you will be in your home directory. To see the names of the directories and files that are already in your home directory, type ls:

linux3[1]% ls
Desktop  Mail  mail
linux3[2]%

ls stands for ``list'', it lists the items in the current directory. You should see mail and possibly some other files and directories. Directories are like folders in Windows. You should create directories as needed to keep your files orderly. Make a directory called 201 by typing the command mkdir 201. Then, type ls and you'll see the name of the directory that you just created.

linux3[2]% mkdir 201
linux3[3]% ls
201  Desktop  Mail  mail
linux3[4]%

To change into the 201 directory, type cd 201. Now type ls.

linux3[4]% cd 201
linux3[5]% ls
linux3[6]%

Notice ls did not give any output. That means that there are no files in this directory. Now make a directory for your project 0 in this 201 directory, by typing mkdir proj0. Then type ls to see the results.

linux3[6]% mkdir proj0
linux3[7]% ls
proj0
linux3[8]%  

Make directories for project 1 through project 5. Again, type ls to see the results.

linux3[8]% mkdir proj1
linux3[9]% mkdir proj2
linux3[10]% mkdir proj3
linux3[11]% mkdir proj4
linux3[12]% mkdir proj5
linux3[13]%  ls
proj0  proj1  proj2  proj3  proj4  proj5
linux3[14]%  

Now go into the proj0 directory by typing cd proj0. Normally you will make a file by using a text editor, but to make this a quick exercise, we'll create an empty file (a file that has a name, but has nothing in it) using the Unix touch command. To make an empty file called proj0.c, type touch proj0.c. Then, type ls and see that you have a file in this directory called proj0.c.

linux3[15]% cd proj0
linux3[16]% touch proj0.c
linux3[17]% ls
proj0.c
linux3[18]%

The cp command allows you to make a copy of a file or directory and give it a different name. Type cp proj0.c copy.c. Then, type ls to see that you have two files now, one called proj0.c and one called copy.c.

linux3[18]% cp proj0.c copy.c
linux3[19]% ls
copy.c	proj0.c
linux3[20]%

The mv command allows you to move a file and/or change a file's name. Type mv copy.c same.c. Then, type ls to see that the files are now called proj0.c and same.c.

linux3[20]% mv copy.c same.c
linux3[21]% ls
proj0.c  same.c
linux3[22]%

The rm command allows us to remove or delete a file. Type rm same.c You may be prompted to make sure that you really do want to delete this file. Answer with a lower case y. If you then type ls, you will notice that the only file in the directory is proj0.c, same.c no longer exists.

linux3[22]% rm same.c
rm: remove `same.c'? y
linux3[23]% ls
proj0.c
linux3[24]%

We have used the cd command before to move into subdirectories by typing cd and the directory name. Using the cd command, without a directory name following it, will take you to your home directory. Type cd and then ls and you should recognize the files that are in your home directory.

linux3[24]% cd
linux3[25]% ls
201  Desktop  Mail  mail
linux3[26]%

The pwd command tells you your current directory. It stands for ``print the working directory''. Type pwd and you will see the full path to your home directory. Mine is /afs/umbc.edu/users/b/o/bogar/home and yours will be similar.

linux3[26]% pwd
/afs/umbc.edu/users/j/m/jmccla3/home/
linux3[27]%

Now let's change directory into our proj0 directory again by typing cd 201/proj0. Typing pwd will reveal the full path to this directory is /afs/umbc.edu/users/ ... /home/201/proj0.

linux3[27]% cd 201/proj0/
linux3[28]% pwd
/afs/umbc.edu/users/j/m/jmccla3/home/201/proj0
linux3[29]%

We can also use the cd command to go up one level in the directory tree. Type cd .. (be sure to type the two dots). Now type pwd and you'll see that you have gone up one directory and are now in your 201 directory.

linux3[29]% cd ..
linux3[30]% pwd
/afs/umbc.edu/users/j/m/jmccla3/home/201
linux3[31]%

Once you understand how to move around, you can give more complicated commands like, for example, cp fileheader.c ../proj2/

Now copy the .emacs file (be cognizant of the dot before emacs) from my cs201 directory into your home director by following these steps:

  1. cd (changes you to your home directory)
  2. pwd (to make sure you are in your home directory)
  3. cp /afs/umbc.edu/users/b/o/bogar/pub/.emacs . The space and the dot after the full path name and filename mean that you want to copy that file into your current directory (a single dot stands for ``current directory'' just as two dots stand for ``parent directory''.)
  4. Files whose names begin with a dot aren't shown to you when you give the ls command. They are called hidden files and they are typically files that are accessed by software you are using. In this case what is in the .emacs file is the settings we want you to use when using the XEmacs editor. These settings will give you perfect indentation according to the course standards automatically. To see the hidden files in your home directory, type ls -a
linux3[31]% cd
linux3[32]% cp /afs/umbc.edu/users/b/o/bogar/pub/.emacs .
linux3[33]% ls -a
.  ..  .cshrc .emacs  201  Desktop  Mail  mail
linux3[29]%
You can check out the contents of that .emacs file by using some Unix commands listed in the Unix Cheat Sheet (hint--try 'more', 'less', or 'cat), but it will probably look like gobbledygook for now.