You are on page 1of 3

CS351

Operating System I
Commands
ls Command used to list all the files in the current working directory.
Example:
yasmina@ubuntu:~$ ls
Desktop Downloads Music Public Videos
Documents examples.desktop Pictures Templates

cd Command used to change into another directory (path).


cd path
Example:
yasmina@ubuntu:~$ cd /home/yasmina/Desktop

yasmina@ubuntu:~/Desktop$ cd .. used to go back from your current


directory.

pwd Command used to display present used directory.


Example:
yasmina@ubuntu:~/Desktop$ pwd
/home/yasmina/Desktop

cal Command used to display the calender.


Example:
yasmina@ubuntu:~/Desktop$ cal
May 2011
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

touch command used to create file.


touch filename
Example:
yasmina@ubuntu:~/Desktop$ touch file.txt

Fall 2011 Page 1


mkdir command used to create directory.
mkdir directoryname
Example:
yasmina@ubuntu:~/Desktop$ mkdir OS1

mv command used to cut file from directory and paste it into another directory.
mv filename(source) newpath(destination)
Example:
yasmina@ubuntu:~/Desktop$ mv file.txt OS1/ cut file.txt and paste in OS1
with the same filename.
yasmina@ubuntu:~/Desktop$ mv file.txt OS1/Osfile.txt cut file.txt and paste
in OS1 with change its name to Osfile.txt .

cp command used to copy file.


cp filename(source) path(destination)
yasmina@ubuntu:~/Desktop$ cp OS1/file.txt OS1_new/ copy file.txt to
OS1_new with the same filename.
yasmina@ubuntu:~/Desktop$ cp OS1/file.txt OS1_new/newfile.txt copy
file.txt to OS1_new with change its name to newfile.txt .
yasmina@ubuntu:~/Desktop$ cp *.txt OS1/
Copy all files ending in .txt into the OS1 directory.
yasmina@ubuntu:~/Desktop$ cp -r * /home/yasmina/Desktopbackup/
Copies all the files, directories, and subdirectories in the files directory into the
/home/yasmina/Desktopbackup directory.

rm command used to delete file.


rm filename
Example:
yasmina@ubuntu:~/Desktop$ rm OS1/file.txt
yasmina@ubuntu:~/Desktop$ rm OS1/*.txt
remove all files ending in .txt into the newdir directory.
yasmina@ubuntu:~/Desktop$ rm -r OS1/*
remove all the files, directories, and subdirectories in OS1 directory.

pico command used to edit file contents.


pico filename
Example
yasmina@ubuntu:~/Desktop$ pico file1.txt

after editing press Ctrl+x then press y to exit and save.

Fall 2011 Page 2


chmod command used to change file permissions (readable, writable,
Executable).
chmod [Option] filename
[Option]:
+ to add permission
- to remove permission
permissions:
x execute
r read
w write

Example:
root@ubuntu:/# chmod +x file.sh file.sh will be executable.
root@ubuntu:/# chmod -r file.sh file.sh will not be readable.
root@ubuntu:/# chmod +xw file.sh file.sh will be executable and writable.

sudo su command used to switch to root.


Exit command to return back to your user (back from root).
_______________________________________

Fall 2011 Page 3

You might also like