0% found this document useful (0 votes)
229 views

Unix Assignment 2

The document discusses various UNIX commands: 1. It provides commands to navigate between directories like 'cd' and copy directory structures with 'cp -R'. 2. The 'du -s -b' and 'date' commands are used to check disk usage, time, and date formatting. 3. Various file manipulation commands are demonstrated like 'cat' to create files, 'find' to search, and 'sed'/'grep' to filter records in files.

Uploaded by

Kool Deepak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views

Unix Assignment 2

The document discusses various UNIX commands: 1. It provides commands to navigate between directories like 'cd' and copy directory structures with 'cp -R'. 2. The 'du -s -b' and 'date' commands are used to check disk usage, time, and date formatting. 3. Various file manipulation commands are demonstrated like 'cat' to create files, 'find' to search, and 'sed'/'grep' to filter records in files.

Uploaded by

Kool Deepak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIX

1. Create a tree structure named training in which there are 3 subdirectories level 1 , level2 and cep . Each one is again further divided into 3. The level 1 is divided i to sdp , re and se . From the subdirectory se how can one reach the home directory in o step and also how to navigate to the subdirectory sdp in one step? Give the comman ds, which do the above actions? Ans : To navigate from 'se' to home directory,in one step,the command is : cd To navigate from 'se' to 'sdp',in one step,the command is : cd ../b 2. How will you copy a directory structure dir1 to dir2 ? (with all the subdirec tories) Ans : cp R dir1 dir2 3. How can you find out if you have the permission to send a message? Ans : ls -l ( To check access permissions) 4. Find the space occupied ( in Bytes) by the /home directory including all its subdirectories. Ans : du -s -b 5. What is the command for printing the current time in 24-hour format? Ans : date +%T 6. What is the command for printing the year, month, and date with a horizontal tab between the fields? Ans : date +%Y%t%B%t%e 7. Create the following files: chapa, chapb, chapc, chapd, chape, chapA, chapB, chapC, chapD, chapE, chap01, chap02, chap03, chap04, chap05, chap11, chap12, cha p13, chap14, and chap15. Ans :The general syntax is : cat > filename Type the contents of file Press Ctrl+D cat > chapa Type the contents of file Ctrl+D Cat > chapb Type the contents of file Ctrl+D Cat > chapc Type the contents of file Cat > chapd Type the contents of file Ctrl+D Cat > chape Type the contents of file Ctrl+D

Cat > chapA Type the contents of file Ctrl+D Cat > chapB Type the contents of file Ctrl+D Cat > chapC Type the contents of file Ctrl+D Cat > chapD Type the contents of file Ctrl+D Cat > chapE Type the contents of file Ctrl+D Cat > chap01 Type the contents of file Ctrl+D Cat > chap02 Type the contents of file Ctrl+D Cat > chap03 Type the contents of file Ctrl+D Cat > chap04 Type the contents of file Ctrl+D Cat > chap05 Type the contents of file Ctrl+D Cat > chap11 Type the contents of file Ctrl+D Cat > chap12 Type the contents of file Ctrl+D Cat > chap13 Type the contents of file Ctrl+D Cat > chap14 Type the contents of file Ctrl+D Cat> chap15 Type the contents of file

Ctrl+D 8. With reference to question 7, What is the command for listing all files endin g in small letters? Ans : find name *[a-z].* 9. With reference to question 7, What is the command for listing all files endin g in capitals? Ans : find name *[A-Z].* 10. With reference to question 7, What is the command for listing all files whos e last but one character is 0? Ans : find name *0?.* 11. With reference to question 7, What is the command for listing all files whic h end in small letters but not a and c ? Ans: find name *[b d-z].* 12. In an organisation one wants to know how many programmers are there. The emp loyee data is stored in a file called personnel with one record per employee. Ever y record has field for designation. How can grep be used for this purpose? Ans : grep -c "programmers" personnel 13. In the organisation mentioned in question 12 how can sed be used to print on ly the records of all employees who are programmers. Ans : sed -n /programmers/p personnel 14. In the organisation mentioned in question 12 how can sed be used to change t he designation programmer to software professional every where in the personnel Ans : sed 's/programmer/software professional/g' personnel 15. Find out about the sleep command and start five jobs in the background, each one sleeping for 10 minutes. Ans :sleep 10m & sleep 10m & sleep 10m & sleep 10m & sleep 10m & 16. How do you get the status of all the processes running on the system? i.e. u sing what option? Ans : ps -e file

You might also like