Lab2. Linux Commands
$ 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
File size
Creation date
File name
Owner of the file
Group of the file
Acces rights:
directory |
Owner |
Group |
Others |
- |
rwx |
rw- |
r-- |
d |
rw- |
rw- |
r-- |
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 command is worked on the background .
[1] à indicates the
PID number, 770 à indicates
the process id0
$ sort list > sortedlist &
[1] 770
$ 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
Lists the background and suspended processes then restarts the
suspended process sleep 100.
[1] Suspended sleep 100
[2] running netscape
[3] running nedit
$ 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