Sie sind auf Seite 1von 7

Beyond Syllabus

Learnings 2

1) pwd- shows the current directory

2) ls
a. To list the directory content command ls is used
b. List directory content in long form -l
c. To list hidden files -a
3) cd
a. Using absolute path: eg $ cd /usr/local[Enter]
b. Using relative path: eg $ cd bin[Enter]
4) Cd ..: Every directory holds two references to special subdirectory:
single (.) that is a reference to the current directory.
double (..) that is a reference to the previous directory.
a. $ cd ..[Enter]
b. $ cd ../bin[Enter]- /usr/bin
c. $ cd ../../var/tmp[Enter]- /var/tmp
d. $ cd /usr/bin/../local/bin/..[Enter]- /usr/local
e. $ cd ./bin[Enter]- /usr/local/bin
5) mkdir:
a. $ mkdir mydir[Enter]- later check with ls l to see file type as directory
b. $ mkdir pis pis/progs pis/data - Creating a parent directory and its child/
c. $mkdir pis/progs pis/data pis- Demonstrate that this doesnt work
6) rmdir:
a. $ rmdir mydir2[Enter]
b. $ rm -r mydir2[Enter]- to remove directory even if it is not empty
7) Example on mkdir and rmdir
$ mkdir carbon[Enter]
$ mkdir carbon/hydrogen[Enter]
$ mkdir carbon/oxygen[Enter]
$ mkdir carbon/hydrogen/helium[Enter]
$ rmdir carbon[Enter]- rmdir: carbon: Directory not empty
$ rm -r carbon[Enter]
8) Directory copy: $ cp -r mydir mydir2[Enter]
9) Cat
i. Create text file called foo.txt
b. $ cat > foo.txt output is as below
This is a test.

Hello world!
press CTRL+D to save file
c. To display contents of file
i. $ cat foo.txt
d. To append contents to existing foo.txt
i. $ cat >> foo.txt
e. To concatenate files do.txt and so.txt and redirect output to foo.txt
i. $ cat do.txt so.txt > foo.txt
f. For the input .. instead of using the standard input (keyboard)
i. $ cat < foo.txt
10) cp
a. to copy contents of file do.txt to file foo.txt- $cp do.txt foo.txt
b. To copy multiple files - $cp chap01.txt chap02.txt chap03.txt progs
11) mv: In Unix environment rename and moving a file are the same thing
a. Rename file- $mv deepali.txt nayak.txt
b. To move file deepali.txt to new directory nayak- $mv deepali.txt nayak
c. To move file deepali.txt one directory back- $mv deepali.txt ../
12) rm
a. $rm deepali.txt
13) $clear
14) date
a. Current date and timestamp of the server- $date
b. Set the date to a date and time shown- $ date -s "20/07/2013 12:48:00"
c. Change format of current date and timestamp- $ date '+DATE: %m/%d/%y
15) cal
a. To obtain calendar for this current month- $cal
b. To obtain calendar for specific month and year- $cal mm yyyy
16) history
a. To see last 500 commands used by me- $history
17) man
a. To list info on mkdir command- $man mkdir
b. To search commands matching keyword provided- $man k irc
Create the following directory structure and be sure your current working directory is
MYDIR when you try the following.
MYDIR is the root directory


1. Copy the file red to BLENDED directory using full path.

2. Remove the file from BASIC directory

3. Copy back the file red from BLENDED directory to BASIC directory using relative

4. Display the present working directory

5. Move the file dog from MAMMALS to SHAPE using FULL path

6. Move back the file dog to its original place using relative path

7. Copy the files red green to directory REPTILES

8. Copy the whole directory COLORS to SHAPE

9. What will be the result if cd : command is executed without any argument ?

10. What will be the result of cd ~

11. Remove all the directories under ANIMALS

12. Now your current working directory is BLENDED

a. Create a file rat under MAMMALS using relative path
b. Move rat to SHAPE using relative path