![]() |
---|
pwd shows you to print your working directory.
tree1:~> pwd
tree1:~> /afs/ir.stanford.edu/users/j/o/joesmo
ls lists the files and directories (called subdirectories) within your present working directory.
tree1:~>ls
tree1:~> APPLES
ls -l is used the same way and displays full information, including access information.
cd allows you to change directories. Let's move to the subdirectory APPLES.
tree1:~> cd APPLES
tree1:~/APPLES>
Using cd . will always return you to your home directory. Using cd .. will take you to the directory one level up (the
directory in which your current directory is in). mkdir (making a new directory) and rmdir (deleting a directory) work the
same way.
mv allows you to rename a directory or move it elsewhere. Let's move a file called fruit.txt in the APPLES directory
into our home directory ("~").
tree1:~/APPLES>mv fruit.txt ~
tree1:~/APPLES>cd .
tree1:~>ls
tree1:~>APPLES
cp allows you to copy a file. Let's copy fruit.txt to pear.txt
tree1:~>cp fruit.txt pear.txt
tree1:~>ls
tree1:~>APPLES
rm allows you to delete a file. Let's delete pear.txt.
tree1:~>rm pear.txt
tree1:~>ls
tree1:~>APPLES
more displays a file until the screen is filled and then displays the next screen when you hit space.
tree1:~>more fruit.txt
Setting Permissions
There are two ways to set permission. Here are examples of both ways. We are simulating setting permissions for fruit.txt.
chmod-method 1.
tree1:~>chmod u=rwx go=r fruit.txt
tree1:~>ls -l fruit.txt
-rwxr--r-- 1 joesmo 37 22016 Oct 8 01:29 fruit.txt
chmod-numerical method. (r=4, w=2, x=1)
tree1:~>chmod 744 fruit.txt
tree1:~>ls -l fruit.txt
-rwxr--r-- 1 joesmo 37 22016 Oct 8 01:29 fruit.txt
Transferring files through FTP
An FTP scenario - getting a file mm.txt and sending a file fruit.txt
tree1:~>ftp transfer.stanford.edu
Connected to transfer.stanford.edu.
220 transfer.Stanford.EDU FTP server (Version 4.162 Tue Nov 1 10:50:37 PST 1988) ready.
Name (transfer.stanford.edu:joesmo): joesmo (*or press enter*)
331 Password required for joesmo.
Password: (*enter password, typing is hidden and will not show up on screen*)
230 User joesmo logged in.
ftp> cd /afs/ir.stanford.edu/users/t/h/thumper
250 CWD command successful.
ftp>ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
mm.txt
peek.txt
PEN
FILES
226 Transfer complete.
116 bytes received in 0.063 seconds (1.79 Kbytes/s)
ftp>get mm.txt (*leave local name blank if you want it to be the same as the remote name)
local: mm.txt remote: mm.txt
22027 bytes received in 0.035 seconds (607.87 Kbytes/s)
ftp> put fruit.txt
local: fruit.txt remote: fruit.txt
22027 bytes sent in 0.0046 seconds (4692.57 Kbytes/s)
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
mm.txt
peek.txt
PEN
FILES
fruit.txt
226 Transfer complete.
116 bytes received in 0.063 seconds (1.79 Kbytes/s)
ftp>quit
221 Goodbye.
tree1:~>ls
tree1:~>APPLES
(Un)Compressing and (Un)Archiving Files
tar cvf - creates archives with little compression.
tree1:~> tar cvf new.tar fruit.txt happy.txt secret.txt
fruit.txt
happy.txt
secret.txt
tree1:~>ls
tree1:~>APPLES
gzip - compresses files
tree1:~> gzip new.tar
tree1:~>
tree1:~>ls
tree1:~> APPLES
tar xvfz - uncompresses and unarchieves (z as a switch = gunzip)
tree1:~> tar xvfz new.tar.gz
fruit.txt
happy.txt
secret.txt