| 19
Working with Files
First, create a directory (i.e. folder) for today’s session, move to it, and verify where you are:
Now copy some files to it and get a directory listing. Be careful with your typing, and don’t ignore
error messages!
The command ‘ls ’ simply lists the contents of the directory you are in.
Now to learn how to rename files and delete them.
cd ~
mkdir unixintro
cd unixintro
Change directory to your home
directory
Make directory ‘unixintro’
Change directory to ‘unixintro’
cp /usr/share/unixintro/* .
ls
Copy all the files in a directory to
the current working directory.
Asterisk (*) means ‘all files’.
Dot (.) means ‘current working
directory’.
IMPORTANT: There is a space between
the Asterisk (*) and the Dot(.)
List all files in the current working
directory
cp phonebook junk
mv junk junk2
ls
rm junk2
ls
Copy file (or folder) phonebook to
junk
Move a file (in this instance, we’re
moving the file ‘junk’ to ‘junk2’,
effectively renaming it.
List all files in the current working
directory
Remove the file (or folder) junk2
List all files in the current working
directory
20
|
Executing Commands
For upcoming labs and courses, you will require many different commands. Probably the most basic
of these is ‘ping ’. Try running the following command to ping the Google OpenDNS Server (8.8.8.8)
located at 10.203.1.5
What is ‘ping’?
The command you just ran, ‘ping’, is a command designed to test the connectivity between two
networked computers. Simply put, the ping command sends ICMP packets from your computer
to the target computer (in this case, 10.203.1.5), which then returns the packets to your computer.
Your computer measures the journey time of each individual packet, deriving metrics from this,
thus giving you useful information about the network connection and possibly the machine you’re
‘pinging’.
Example
tundra:~ msai135$ ping -c 5 -n 10.203.1.5
PING 10.203.1.5 (10.203.1.5): 56 data bytes
64 bytes from 10.203.1.5: icmp_seq=0 ttl=63 time=0.536 ms
64 bytes from 10.203.1.5: icmp_seq=1 ttl=63 time=0.562 ms
64 bytes from 10.203.1.5: icmp_seq=2 ttl=63 time=0.645 ms
64 bytes from 10.203.1.5: icmp_seq=3 ttl=63 time=0.668 ms
64 bytes from 10.203.1.5: icmp_seq=4 ttl=63 time=0.640 ms
--- 10.203.1.5 ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.536/0.610/0.668/0.052 ms
tundra:~ msai135$
ping -c 5 -n 8.8.8.8
Ping the IP Address 10.203.1.5
for a count of 5 (-c 5), outputting
numerical values only (-n)
|