Lists the background and suspended processes then restarts the suspended process sleep 100. |
|
Directory |
Owner |
Group |
Others |
- |
rwx |
rw- |
r-- |
D |
rw- |
rw- |
r-- |
Acces rights:
first column indicates that it is directory or file. If it is directory, d is present otherwise it is empty,
next 3 column groups indicate the file permissions of the owner of the file or directory, group of people to whom the f,le or directory belongs and other users respectively.
on file:
r : read and copy the file
w : change the file
x : execute a file
on directory:
r : allows users to list files in the directory
w : allows users to delete files from the directory or move files into it
x : allows to access files in the directory
$ chmod (change mode)
this command is used for changing access rights of the file or directory
$ chmod go –rwx biglist : remove read, write and execute permissions on the file biglist for the group and others.
$chmod a+rw bigfile : add read and write permission on the file bigfile for all users
$chmod 500 list1 : gives read and execute permission to the owner and removes rest of the permissions
- r-x --- ---
- 101 000 000 (=5 0 0)
C. Processes and Jobs
A process is an executing program identified by a unique PID (process identifier). It can be in background, in foreground or be suspended.
$ ps
this command is used for seeing information about the processes.
$ps –aux : used for seeing the processes in details
&
this symbol is used for working the process on the background.
$ sort list > sortedlist & [1] 770
|
|
Sort command is worked on the background .
[1] à indicates the PID number, 770 à indicates the process id0 |
|
bg this command is used for background a current foreground process.
$ fg this command is used for foreground a background or suspended process
|
|
|
|
This is used for background a current working process |
|
|
|
$ sleep 100 ^Z # bg
$ jobs
this command is used for listing suspended and background processes
$ jobs
[1] Suspended sleep 100 [2] running netscape
$ fg 1
^Z this is used for suspending a job
^C this is used for killing a job
$ kill this command is used for killing suspended or background process
|
|
|
|
sleep 100 jobs is killed. If the process refuses to be killed, -9 option is used ($ kill -9 20077) |
|
|
|
$ ps PID TTY STAT TIME COMMAND 20077 pts/5 S 0:05 sleep 100 21357 pts/5 T 0:00 netscape $ kill 20077
|
OPERATING SYSTEM LAB. MANUAL
Lab.1 : Linux Commands:
$ ls (list short)
this command is used for finding out what is in the current directory. It list the contents of the current working directory.
$ ls –a : used for listing all files including hidden
$ ls –l : used for listing all files in details excluding hidden files
$ ls list* : used for listing the files that names start with “list” in the current workng director
$ ls *list : used for listing the files that names ends with “list” in the current working directory
$ ls ~/betul : used for listing the contents of your betul directorywhich isunder your home directory
$ mkdir (make directory)
this command is used for creating a new directory into the present working directory.
$ mkdir betul : used for creating a directory called betul into the current working directory.
$ cd (change directory)
this command is used for changing the cureent working directory to a different directory.
$ cd betul : changes the current working directory to the directory called betul
$ cd : used for returning the home directory
$ cd .. :used for taking one directory up in the hierarchy
Note: In unix and linux there are two special directories called ‘.’(dot) and ‘..’(two dot or double dot). ‘.’ means the current directory and ‘..’ means the parent of the current directory
$ pwd (print working directory)
this command is used for finding out the absolute pathname of your present working directory.
$ cp (copy)
this command used for copying files.
$ cp filename copy-filename : is used for copying a file with another name at the same directory
$ cp filename directoryname : is used for copying a file from the current directory to another subdirectory. In this case the file is copied with the same name
$ cp filename directoryname/new-filename : is used for copying a file from the current directory to another subdirectory. In this case the file is copied with diffrent name.
$ cp ../filename : is used for copying the file from the directory above (represented by “..”) to the current directory
$ mv (move)
this command is used for renaming or moving files.
$ mv old-filename new-filename : renames original file with new-filename
$ mv filename directory-name/filename : moves file to another directory with keeping the same filename
$ mv filename directory-name/new-filename : moves file to another directory with giving another filename
$ rm (remove)
this command is used for deleting files.
$ rm filename : removes file from the current directory
$ rm director-name : removes the file from another directory
$ rm ../filename : removes file from directory above
$ rmdir (remove directory)
this command is used for removing directory. Note that unix will not allow removing non-empty directories.
$ rm –r directory-name : is used for removing a directory with files. ( -r means recursive)
$ clear (clear screen)
this command clears all text and leave $ prompt at the top of the window.
$ find
this command is used for finding files. It is used with –name flag. The directory must be specified.
$ find . –name myfile : searches the file called myfile in the current directory
$ find directory/ -name myfile : seaches the file called my file in the given directory
$ less
this command is used for displaying the contents of a file on the screen. It wites the contents of a file onto the screen a page at a time.
$ less filename
$ head
this command is used for displaying the contents of a file on the screen. By deafult it displays first ten lines of a file.
$ head –6 myfile : displays the first 6 lines of the file
$ tail
this command is used for displaying the contents of a file on the screen. By deafult it displays last ten lines of a file.
$ tail –6 myfile : displays the last 6 lines of the file
$ wc (word cout)
this command is used for finding out how many lines the file has.
$ wc –l science.txt
$ cat (concatenate)
this command is used for displaying the contents of a file on the screen. If the file is longer than the size of the window, it scrolls past making it unreadable
$ cat filename
If the cat command is written without specifying a file to read, it reads the standard input and on receiving the “end of file” (^D), copies it to the standard output.
Ex1. Ex.2
$ cat $ cat
bir bir
iki bir
uc iki
^D iki
bir uc
iki uc
uc ^D
$ $
The ‘>’ symbol is used for redirecting the output of a command.
$ cat > list1
apple
banana
pear
^D
The ‘>>’ symbol is used for appending standard output to a file.
$ cat >>list1
grape
pineapple
^D
$ cat list1 list2 >biglist : writes the contends of the list1 and list2 into the file called biglist respectively.
$ grep
this command is used for searching files for specified words or patterns. It is case sensitive.
$ grep science science.txt : search science word in the science.txt file and print out each line containing the word science.
$ grep –i ‘spinning top’ science.txt : search ’spinning top’ pattern in the science.txt file with ignoring upper*lower case distinctionss
options of grep command:
-v : displays those lines that do not match
-n : precede each matching line with the lin number
-c: prints only the total count of matched lines
$ grep –ivc science science.txt : displays the number of lines without the words science or Science
$ sort
this command is used for sorting alphabetically or numerically sorts a list.
$ sort
carrot
beetroot
artichoke
^D
artichoke
beetroot
carrot
$ sort < biglist ($ sort biglist ) : outputs the sorted list to the screen
$ sort < biglist > sortedlist : writes the output of the sorted list into the file called sortedlist
$ who
this command is used for seeing who is on the system with you
cmd1 | cmd2 (Pipes)
using pipes, the output of the command1 can be used as input for command2
$ who | sort : sorted list of the names who is on the system
$ who | wc –l : find out how many users are logged on
$ man
this command is used for getting help about the specified command usage.
$ man cat : displays the cat command usage information
B4. File System Security
In unix each file and directory has associated access rights which may be found by typing ls –l or ls lg.
-rwxrw-r-- 1 ee51ab beng95 2450 feb10 11:50 file1
|
Access rights |
Owner of the file |
|
Group of the file |
|
Size of the file |
|
Creation date |
|
File name |
|
|
|
|
|
|
|
|
|
|
|
|
|