Professional Documents
Culture Documents
CSEN3113 Assignments Day 1enlarged
CSEN3113 Assignments Day 1enlarged
Day1 Lessons
Self Assessment with General Purpose Utilities in UNIX-like Systems
1. What is a directory?
A directory contains no data, but keeps some details of the files and subdirectories that it
contains. A directory contains the filename and not the file’s contents. If we have 20 files
in a directory, there will be 20 entries in the directory. Each entry has two components
the filename and unique identification number (inode).
3. Operations on directories:
a. Check the current directory. pwd
b. Change the current directory. cd
c. Create new directory (s). mkdir command is followed by names of the
directories to be created.
$ mkdir asgn asgn/a asgn/a/h asgn/a/g asgn/b asgn/c asgn/c/d asgn/c/d/e
d. Remove directory (s).--> removes directory
$ rmdir asgn asgn/a asgn/a/h asgn/a/g asgn/b asgn/c asgn/c/d asgn/c/d/e
4. Absolute pathnames, Relative pathnames.
Command: oslab/a/g$ cat f1 will work only if f1 exists in your current directory, i.e., g.
If you are placed in : oslab and want to access f1 in : oslab/a/g,
you have to use : oslab$ cat a/g/f1 (two levels down). This fully qualified pathname is called absolute
pathname.
Relative pathnames: : From oslab/c/d/e$ if I want to move up to oslab cd ../../..
Page 1 Aug-21
CSEN3113 – OS Lab Assignments-Day1
5. What is a command?
It is an instruction given to the OS, interpreted by SHELL.
Most commands are external in nature, but there are some which are not really found anywhere, and some which are
normally not executed even if they are in one of the directories specified by PATH.
echo isn’t an external command, because, when we type echo, the shell won’t look in its PATH to locate
it (the command file is there in /bin). The shell will execute it from its own set of built-in
commands that are not stored as separate files. These built in commands are internal commands.
6. What is ls Command?
ls → listing of files and directories, i.e., the file names under current directory...
:oslab$ ls → too little information is coming
:oslab/b$ ls -alh
total 20K
→ The word "total" is followed by the number of file system blocks that the directory's files occupy. → using the
-h option together with -l this will have the output in k,M,G for a better understanding.
drwxrwxr-x 2 user user 4.0K Jul 5 16:15 .
drwxrwxr-x 5 user user 4.0K Jul 4 15:32 ..
-rw-rw-r-- 1 user user 3.2K Jul 5 16:15 f1
-rw-rw-r-- 1 user user 3.2K Jul 5 16:15 f2
-rw-rw-r-- 1 user user 3.2K Jul 5 16:15 f3
Page 2 Aug-21
CSEN3113 – OS Lab Assignments-Day1
with the permission flags to determine what access rights you have. The file size follows the group name; it is
measured in bytes. Regardless of how many files it contains, the size of a directory is normally 4096 bytes.
A calendar date appears after the file size. It may also include the year or a specific time. This is the date when the item was
last modified;
:oslab$ ls -lt → Filenames sorted by last modification time
:oslab$ ls -lu→ Filenames sorted by last access time
:oslab$ ls -li→ Filenames sorted by inode number
:oslab$ ls –x output in multiple columns
:oslab$ ls –Fx Identifying Directories and executables (-F)
:oslab$ ls –axF Showing Hidden files also (-a)
:oslab$ ls -lR → Recursive file list
8. How to display the user currently working on the system? This means whats going on around
you Who are you? Commands like whoami, who am i., id. Question may also be asked
Finding out what other users are logged in to the system. Who else is there? Commands users,
who, who -Hu, w.
9. How to display the name and version of your operating system? The uname command
displays certain features of the os running on your machine. :~/Desktop/oslab$ uname
:oslab$ uname –r the current release
:oslab$ uname –n shows host name or the complete domain name
Knowing your terminal: Linux treats terminals as files.
:oslab$ tty
/dev/pts/10 a file named 10 is resident in pts directory.
11. How to display the current system date and time in a variety of formats?
oslab$ date displaying system date
oslab$ date +%m only the month
oslab$ date +%h month name
oslab$ date +”%h %m” combine July 07 in one command
Other formats:
d day of the month (1 to 31)
y the last two digits of the year
H, M and S hour, minute and second
D The date in the format mm/dd/yy
T The time in the format hh:mm:ss
Page 3 Aug-21
CSEN3113 – OS Lab Assignments-Day1
Page 4 Aug-21
CSEN3113 – OS Lab Assignments-Day1
5. comm: What is Common between two files? Compare two sorted files line-by-line.
user@user-HP-Pro-3330-MT:~/Desktop/oslab/c$ comm f3 f4
Eggs
comm: file 1 is not in sorted order
Page 5 Aug-21
CSEN3113 – OS Lab Assignments-Day1
user@user-HP-Pro-3330-MT:~/Desktop/oslab$ w
09:16:39 up 18 min, 8 users, load average: 0.00, 0.06, 0.10
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
user tty4 09:08 8:23 0.10s 0.06s -bash
user tty5 09:08 8:07 0.09s 0.06s -bash
user tty2 09:07 9:03 0.10s 0.06s -bash
user tty3 09:08 8:31 0.12s 0.06s -bash
user tty6 09:08 7:59 0.09s 0.06s -bash
user tty1 09:07 9:19 0.08s 0.06s -bash
user :0 :0 09:04 ?xdm? 17.70s 0.10s init --user
user pts/7 :0 09:05 7.00s 0.03s 0.00s w
Page 6 Aug-21