UNIX Assignment Day1
UNIX Assignment Day1
Ans. UNIX architecture have four layer 1 Hardware It is hardware part which have machine on which UNIX will be installed and UNIX will manage interfare in between Hardware and software. 2 Kernal It may be called as core and its work as a resource manager. It manages scheduling . 3 Shell It provides user interface to access the machine . There are so many shell are there. It execute user command.
Ans. Unixs four important features are 1. Multitasking 2. Multiuser 3. Free of cost 4. It is open source operating system
3. A directory in a UNIX system contains following files: .bash_profile, .bashrc, .bash_history, .inputc, .bash_script, manch01.txt, manch02.txt, manch03.txt, manch04.txt, manch05.txt, manch10.txt, manch12.txt, manch20.txt, manch21.txt, manch30.txt, fold.exe, gawk-3.1.8.exe, gdiffmk, getclip.exe, groff.exe, groffer, grog, grolbp.exe, hostid.exe, install-info.exe, join.exe, kill.exe, ldd.exe, lessecho.exe, lesskey.exe, locale.exe, locate.exe, login.exe, logname.exe What will be the output of these 'ls' commands on this list?
MLS/11/UX/OS/001
Page 1
UNIX Assignment a. ls ?
Admins-iMac-2:~ trainee$ ls l*.exe ldd.exe lesskey.exe locate.exe logname.exe lessecho.exe locale.exe login.exe
c. ls loca[t]e.exe
4. Write equivalent 'ls' commands to list files (in the above list) as per following requirements: a. list all 'manch' files with chapter no.s ending with 1
Admins-iMac-2:~ trainee$ ls -l -a manch*1.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch01.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 manch21.txt
b. list all 'manch' files with chapter no.s below 10
Admins-iMac-2:~ trainee$ ls -l -a manch[0]*.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch01.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch02.txt
MLS/11/UX/OS/001
Melior Learning Solutions
Page 2
UNIX Assignment
-rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch03.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch04.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch05.txt
c. list all 'manch' files with chapter no.s 20 or above
Admins-iMac-2:~ trainee$ ls -l -a manch[2]*.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 manch20.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 manch21.txt
d. list all 'manch' files which don't have 0 in their chapter no.s
Admins-iMac-2:~ trainee$ ls -l -a manch[1-9][1-9].txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 manch12.txt -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 manch21.txt
e. long list of all files whose names start with a . (i.e. dot) with full details
Admins-iMac-2:~ trainee$ ls -l -a [a]*.* -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bash_history -rw-r--r-- 1 trainee staff 0 Apr 20 16:32 abhijeet.bash_profile -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 abhijeet.bash_script -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bashrc -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.inputc
f. list all files whose names do not start with 'm'
Admins-iMac-2:~ trainee$ ls -l -a [!m]*.* -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bash_history -rw-r--r-- 1 trainee staff 0 Apr 20 16:32 abhijeet.bash_profile -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 abhijeet.bash_script -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bashrc -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.inputc -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 fold.exe -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 gawk-3.1.8.exe
MLS/11/UX/OS/001
Melior Learning Solutions
Page 3
UNIX Assignment
-rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--
1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee
staff staff staff staff staff staff staff staff staff staff
0 Apr 20 16:36 getclip.exe 0 Apr 20 16:36 join.exe 0 Apr 20 16:36 kill.exe 0 Apr 20 16:36 ldd.exe 0 Apr 20 16:37 lessecho.exe 0 Apr 20 16:37 lesskey.exe 0 Apr 20 16:37 locale.exe 0 Apr 20 16:37 locate.exe 0 Apr 20 16:37 login.exe 0 Apr 20 16:38 logname.exe
5. Give the 'ls' commands to do the following: a. List only directories in a directory
abhijeet_gupta
ls l -R
c. List files sorted in the reverse order of their modification time
ls -l t or ls l t -r
MLS/11/UX/OS/001
Page 4
UNIX Assignment 6. What is the copy command to copy all .txt files from /home/user1 to /home/user2/txt folder? Copy (cp) command to copy of one file content to another file. syntax is cp source_file target_file
Admins-iMac-2:/ trainee$ cp *.txt ./user1/ Admins-iMac-2:/ trainee$ cd user1 Admins-iMac-2:user1 trainee$ ls abhijeet_gupta.txt Admins-iMac-2:user1 trainee$ cd .. Admins-iMac-2:/ trainee$ mkdir user2 Admins-iMac-2:/ trainee$ cp ./user1/*.txt ./user2/ Admins-iMac-2:/ trainee$ cd user2 Admins-iMac-2:user2 trainee$ ls abhijeet_gupta.txt
7. How do you move all .txt files from /home/user1 to /home/user2/txt folder?
Admins-iMac-2:/ trainee$ mv ./user1/*.txt ./user2/ Admins-iMac-2:/ trainee$ cd user1 Admins-iMac-2:user1 trainee$ ls Admins-iMac-2:user1 trainee$
8. 'dir' command DOS (Windows command prompt) gives a detailed list of files in a directory. Write an equivalent 'ls' command for 'dir' in UNIX using 'alias'
dir='ls -a -l'
Admins-iMac-2:~ trainee$ dir total 160 drwxr-xr-x+ 54 trainee staff 1836 Apr 20 16:38 .
MLS/11/UX/OS/001
Melior Learning Solutions
Page 5
UNIX Assignment
drwxr-xr-x 6 root admin 204 Apr 18 20:16 .. -rw------- 1 trainee staff 3 Apr 18 20:16 .CFUserTextEncoding -rw-r--r--@ 1 trainee staff 12292 Apr 19 16:13 .DS_Store drwx------ 2 trainee staff 68 Apr 20 13:20 .Trash -rw-r--r-- 1 trainee staff 12288 Apr 20 12:00 .anil.swp -rw-r--r-- 1 trainee staff 1 Apr 20 14:18 .b* -rw------- 1 trainee staff 307 Apr 20 14:37 .bash_history -rw------- 1 trainee staff 1500 Apr 20 13:18 .c* -rw------- 1 trainee staff 35 Apr 20 11:50 .lesshst -rw------- 1 trainee staff 12288 Apr 20 14:37 .text.mine.swp -rw------- 1 trainee staff 1680 Apr 20 16:15 .viminfo -rw-r--r-- 1 trainee staff 891 Apr 20 15:33 Abhijeet drwx------+ 6 trainee staff 204 Apr 20 16:26 Desktop drwx------+ 5 trainee staff 170 Apr 20 13:18 Documents drwx------+ 13 trainee staff 442 Apr 20 16:10 Downloads drwx------+ 30 trainee staff 1020 Apr 20 12:02 Library drwx------+ 3 trainee staff 102 Apr 18 20:16 Movies drwx------+ 4 trainee staff 136 Apr 20 12:01 Music drwx------+ 5 trainee staff 170 Apr 19 14:56 Pictures drwxr-xr-x+ 5 trainee staff 170 Apr 18 20:16 Public drwxr-xr-x+ 5 trainee staff 170 Apr 18 20:16 Sites -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bash_history -rw-r--r-- 1 trainee staff 0 Apr 20 16:32 abhijeet.bash_profile -rw-r--r-- 1 trainee staff 0 Apr 20 16:34 abhijeet.bash_script -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.bashrc -rw-r--r-- 1 trainee staff 0 Apr 20 16:33 abhijeet.inputc drwxr-xr-x 2 trainee staff 68 Apr 20 16:30 abhijeet_2669 -rw-r--r-- 1 trainee staff 736 Apr 20 16:01 abhijeet_gupta -rw-r--r-- 1 trainee staff 23 Apr 20 14:17 anil -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 fold.exe -rw-r--r-- 1 trainee staff 0 Apr 20 16:35 gawk-3.1.8.exe -rw-r--r-- 1 trainee staff 0 Apr 20 16:36 gdiffmk -rw-r--r-- 1 trainee staff 0 Apr 20 16:36 getclip.exe
MLS/11/UX/OS/001
Melior Learning Solutions
Page 6
UNIX Assignment
-rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--rw-r--r--
1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee 1 trainee
staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff staff
0 Apr 20 16:36 join.exe 0 Apr 20 16:36 kill.exe 0 Apr 20 16:36 ldd.exe 0 Apr 20 16:37 lessecho.exe 0 Apr 20 16:37 lesskey.exe 0 Apr 20 16:37 locale.exe 0 Apr 20 16:37 locate.exe 0 Apr 20 16:37 login.exe 0 Apr 20 16:38 logname.exe 0 Apr 20 16:34 manch01.txt 0 Apr 20 16:34 manch02.txt 0 Apr 20 16:34 manch03.txt 0 Apr 20 16:34 manch04.txt 0 Apr 20 16:34 manch05.txt 0 Apr 20 16:34 manch10.txt 0 Apr 20 16:34 manch12.txt 0 Apr 20 16:35 manch20.txt 0 Apr 20 16:35 manch21.txt 0 Apr 20 16:35 manch30.txt 13 Apr 20 12:38 monika
MLS/11/UX/OS/001
Page 7
UNIX Assignment 9. Type the following passage using vi and save the file The Restaurant at the End of the Universe is one of the most extraordinary ventures in the entire history of catering. It has been built on the fragmented remains of ... it will be built on the fragmented ... that is to say it will have been built by this time, and indeed has been One of the major problems encountered in time travel is not that of accidentally becoming your own father or mother. There is no problem involved in becoming your own father or mother that a broadminded and well-adjusted family can't cope with. There is also no problem about changing the course of history - the course of history does not change because it all fits together like a jigsaw. All the important changes have happened before the things they were supposed to change and it all sorts itself out in the end. The major problem is quite simply one of grammar, and the main work to consult in this matter is Dr Dan Streetmentioner's Time Traveller's Handbook of 1001 Tense Formations. It will tell you for instance how to describe something that was about to happen to you in the past before you avoided it by time-jumping forward two days in order to avoid it. The event will be described differently according to whether you are talking about it from the standpoint of your own natural time, from a time in the further future, or a time in the further past and is further complicated by the possibility of conducting conversations whilst you are actually travelling from one time to another with the intention of becoming your own father or mother. To resume: The Restaurant at the End of the Universe is one of the most extraordinary ventures in the entire history of catering. It is built on the fragmented remains of an eventually ruined planet which is (wioll haven be) enclosed in a vast time bubble and projected forward in time to the precise moment of the End of the Universe. This is, many would say, impossible. In it, guests take (willan on-take) their places at table and eat (willan on-eat) sumptuous meals whilst watching (willing watchen) the whole of creation explode around them. Extracted from Adams, Douglas, "The Restaurant at the End of the Universe"
MLS/11/UX/OS/001
Page 8