Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Bule Hora University Department of Computer Science 2023

Lab practice Manual for Students


Standard directory of Linux

Follow the following Steps


 Start / open your PC
 Choose Ubuntu
 Then click Enter

Now you can start your Project


 Start Terminal
 Write the command written below

Working with Directory

Important standard directories


(/): -root, or ancestor of all files
(/usr): - shows each user‘s home directory
(/dev): - all files that represent peripheral devices
(/etc): - administrative command kept in this directory
(/bin): - contains standard Linux programs
(/tmp): - used for temporary files
(/lib): - store library files

pwd
You are here sign can be displayed with the pwd command (Print Working
Directory).
The tool displays your current directory.
$ pwd
cd
You can change your current directory with the cd command (Change Directory).
$ cd /etc
$ pwd
/etc
$ cd /bin
$ pwd
/bin
cd ~ same with cd
You can pull off a trick with cd. Just typing cd without a target directory, will put you in your
home directory.
Typing cd ~ has the same effect.
$ cd /etc
$ pwd
/etc
cd ..

1
Prepared by Tilksew Sh.
Bule Hora University Department of Computer Science 2023

To go to the parent directory (the one just above your current directory in the
directory tree), type cd ..
$ pwd
/usr
$ cd ..
$ pwd

cd -
Another useful shortcut with cd is to just type cd - to go to the previous directory back and forth.
$ pwd
$ cd /etc
$ pwd
/etc
$ cd -
ls
You can list the contents of a directory with ls.
$ ls
ls -a
A frequently used option with ls is -a to show all files. Showing all files means
including the hidden files. When a file name on a Linux file system starts with a dot,
it is considered a hidden file and it doesn't show up in regular file listings.
$ ls
$ ls –a

ls -l
Many times you will be using options with ls to display the contents of the directory
in different formats or to display different parts of the directory. Typing just ls gives
you a list of files in the directory. Typing ls -l (that is a letter L, not the number 1)
gives you a long listing.
$ ls –l
ls -lh
Another frequently used ls option is -h. It shows the numbers (file sizes) in a more
human readable format. Also shown below is some variation in the way you can give
the options to ls.
$ ls -l -h
$ ls -lh
$ ls -hl
$ ls -h –l
ls –i
used to see the inode number of the file created
$ls –i
Clear
for clearing the terminal
$ clear
mkdir
Walking around the Linux file tree is fun, but it is even more fun to create your own

2
Prepared by Tilksew Sh.
Bule Hora University Department of Computer Science 2023

directories with mkdir. You have to give at least one parameter to mkdir, the name
of the new directory to be created. Think before you type a leading / .
$ mkdir MyDir
$ cd MyDir
/MyDir$ ls -al
/MyDir$ mkdir stuff
/MyDir$ mkdir otherstuff
/MyDir$ ls –l
mkdir -p
When given the option -p, then mkdir will create parent directories as needed.
$ mkdir -p MyDir2/MySubdir2/ThreeDeep
$ ls MyDir2
$ ls MyDir2/MySubdir2
$ ls MyDir2/MySubdir2/ThreeDeep/
rmdir
you can use rmdir to remove the directory.
/MyDir$ rmdir otherstuff
/MyDir$ ls
/MyDir$ cd ..
$ rmdir MyDir
rmdir: MyDir/: Directory not empty
$ rmdir MyDir/stuff
$ rmdir MyDir
rmdir -p
And similar to the mkdir -p option, you can also use rmdir to recursively remove
directories.
$ mkdir -p dir/subdir/subdir2
$ rmdir -p dir/subdir/subdir2
Chmod
Used to set permission for file
1. Symbolic mode
This have 3 parts
a. Users : u – user , g - group member o – other
b. To access or deny permission: (+ to access , - to deny)
c. Permission: (r- read, w- write, x- execute)
2. Absolute mode
We use numbers
0- None
1- Execute
2- Write
4- Read
$ Chmod 764 <file name>

3
Prepared by Tilksew Sh.

You might also like