using unix pages

We have some UsingUnix pages for students new to unix. If this is your first CS course at Swarthmore, those pages are meant to help you understand our setup.

Here’s a table of some basic Unix commands:

Command Examples Description
ls ls list files and directories
ls ls -al list all files, long output format
pwd pwd print working directory (where you are)
cd cd directory change directory
cp cp file newname copy a file to a new name
mv mv file newname move/rename a file
mv mv file directory move file to a directory
less less filename view file one page at a time (q to quit)
mkdir mkdir newdir make a new directory

And here’s an example of using some of the above commands, with typical outputs (username is csmajor1). Note the dollar sign is the unix shell prompt (your prompt may look a little different), and anything after the dollar sign is what the user is typing.

$ ls
Desktop/    Documents/  cs21/
$ pwd
/home/csmajor1
$ cd cs21/labs/00
$ pwd
/home/csmajor1/cs21/labs/00
$ ls -l
total 12
-rw------- 1 csmajor1 users  303 Jan 23 12:22 QUESTIONS-00.txt
-rw------- 1 csmajor1 users  513 Jan 23 12:22 bio.txt
-rw------- 1 csmajor1 users 1766 Jan 23 12:22 fixme-gb.txt
$ cp bio.txt newbio.txt
$ ls
QUESTIONS-00.txt  bio.txt  fixme-gb.txt  newbio.txt
$ mv newbio.txt mybio.txt
$ ls
QUESTIONS-00.txt  bio.txt  fixme-gb.txt  mybio.txt
$ rm mybio.txt 
rm: remove regular file 'mybio.txt'? y
$ ls
QUESTIONS-00.txt  bio.txt  fixme-gb.txt

In the above example the user:


Back to SwatCS Help Docs