Working With Linux
Working With Linux
1
Login and logout
Account
username & password
Note:
Linux is case-sensitive
Administrator: username = root
2
Linux File System
(C) (D) (/)
…. ….
3
Directory/file commands
List contents of directory :
ls [-a] [-l] [directory_name]
Print working directory: pwd
Change working directory :
cd directory_name
E.g. cd /home
Create new directory :
mkdir directory_name
Remove a directory:
rm -r directory_name
Some special symbols :
~ : home directory
.. : parent directory
4
Directory/file commands
5
File system and permissions
6
File system and permissions
7
File system and permissions
8
Changing access rights (1)
Symbolic
chmod who op mode [-R] file(s)
Who: u : owner
g : group
o : others
a : all
Mode: r : read
w : write
x : execute
Op + : grant more rights
- : revoke rights
= : reset rights
9
Changing access rights (2)
Example
$ touch temp
$ ls –l temp
-rw-r--r-- 1 user1 staff 0 Jun 11 11:44 temp
$ chmod o-r temp
$ ls -l temp
-rw-r----- 1 user1 staff 0 Jun 11 11:44 temp
$ chmod u+x, o+r temp
$ ls -l temp
-rwxr--r-- 1 user1 staff 0 Jun 11 11:44 temp
10
Changing access rights (3)
12
Changing access rights (5)
Example
$ touch abc
$ ls –l abc
-rw-r--r-- 1 user1 staff 0 Jun 11 11:44 abc
$ chmod 555 abc
$ ls -l abc
-r-xr-xr-x 1 user1 staff 0 Jun 11 11:44 abc
$ chmod 775 abc
$ ls -l abc
-rwxrwxr-x 1 user1 staff 0 Jun 11 11:44 abc
13
Advanced utilities (1)
Who is who?
who [option]
Print current host name
hostname
Where do they come from?
which [filename]
How much disk usage?
df [option]
Clear screen
clear OR Ctrl + L
14
Advanced utilities (2)
15
vi editor
16
vi usage
syntax meaning
vi filename open/create file
17
Cursor movement in vi
Cmd Meaning
n move cursor left n character(s)
n move cursor down n character(s)
n move cursor up n character(s)
n move cursor right n character(s)
Enter move cursor to beginning of next line
G move cursor to the last line
nw move cursor left n word(s)
nW move cursor right n word(s)
18
Text manipulation commands
Cmd Meaning
nx delete n character(s) from current cursor
position
nX delete n character(s) immediately preceding
current cursor position
D, d$ delete all characters from current cursor
position to end of line
d0, d| delete all characters from left collumn of
screen to character preceding current cursor
position on current line
19
Text manipulation commands
Cmd Meaning
ndd delete n line(s) beginning at current line
dG delete all lines, starting with current line, through
end of file
20
Text manipulation commands
Cmd Meaning
~ change case of current character
r replace single character at cursor position
21
Text manipulation commands
Cmd Meaning
nY, nyy copy (yank) n line(s) into buffer
nyw copy (yank) n word(s) into buffer
22