Blida 1 university First practical work activity level: first year engineer
1. Introduction: The Linux file hierarchy
/: the root
/bin: system commands
/home: connection directories
for users
Other directories are not concerned
by this course
2. Some Linux commands
pwd : (print working directory) displays the absolute path of the current directory ,
ls <name_of_the_directory>: displays the contents of a directory (list); directories and files have different colors.
ls: displays contents of current directory,
ls /home/TPSE1: displays the contents of the TPSE1 directory,
cd <directory_path > : (change directory) change directory
cd - : go to the previous directory ("-" indicates the previous directory)
cd .. go to the directory which is the parent of the current directory (".." indicates the parent
directory),
cd home: go to the home directory,
cd /home/TPSE1/Office: go to the Office directory,
cd ./TPSE1/Desktop: go to the Desktop directory from the current directory ("./ " indicates the current
directory),
cd go to current user directory,
mkdir <name_of_the_directory> : (make directory) creates a new directory ,
mkdir computer: creates the computer directory in the current directory,
mkdir computer math: create the computer and math directories in the current directory,
mkdir /home/TPSE1/desktop/computer: creates the computer directory in the desktop directory
rmdir <directory_name> : (remove directory), removes an empty directory,
rmdir computer: deletes the computer directory in the current directory,
rmdir /home/TPSE1/office/computer: deletes the computer directory in the office folder,
cp <source ...> <destination>: copies source files to destination
cp /home/TP1 /home/TPSE1/Office: copies TP1 file from home directory to Office directory
cp /home/TP1 /home/TP2 /home/TPSE1/desktop: copies TP1 and TP2 files from the home directory to
the desktop directory
cp /home/computer/* /home/TPSE1/Desktop: copies all files in the computer directory to the
Desktop ("*" means everything in the directory),
Note: to copy a directory, use the -R or -r (recursive) option.
cp -R /home/computer /home/TPSE1/desktop: copies the computer directory and its contents from
the home directory to the desktop directory.
Blida 1 university First practical work activity level: first year engineer
Introduction to SE1 module
Université Blida 1 TP1 series Level: 1ère Engineering year
mv <source ...> <destination> : (move), Renames/Moves files or, source directories to destination .
mv TP1 TP2: rename the TP1 file in the current directory to TP2,
mv /home/TP1 /home/TP2: rename the TP1 file in the home directory to TP2,
mv /home/TP1 /home/TPSE1/desktop: moves the TP1 file from the home directory to the desktop
directory
mv /home/TP1 /home/TPSE1/desktop/TP2: move TP1 file from the home directory to the desktop
directory and renames it TP2.
rm <files ...> : (remove), deletes files or directories ,
rm TP1 TP2: removes TP1 and TP2 files from the current directory,
rm /home/TP1 home/TP2: removes the TP1 and TP2 files from the home directory,
Note: to delete a directory and its contents, use the -R (recursive) option.
rm -R /home/computer: deletes the computer directory of the home directory.
Exercise:
1. Where am I?
a- Use the shortcut CTRL+ ALT+ T to open the terminal after starting ubuntu.
What's the name of the directory you're currently in?
b- Which command should we use to display the full path to this directory?
2. Handling folders and files:
a- Create tree 1 using linux commands (in the directory indicated in question 1.a).
b- Give the required commands to go from 1 to 2, 2 to 3, 3 to 4, 4 to 5,5 to 6.
mydesktop
mydesktop mydesktop
Folder 1
Folder1 File1 Folder 1
Folder 2 Folder 3
Folder 2 Folder 3
Folder2 Folder3
Folder3 File1 Folder4
File1 Folder 4
Folder4 File1 Folder4
1 2 3
mydesktop mydesktop
mydesktop
Folder1 Folder1
Folder1
Folder2 Folder2
Folder2 Folder3
Folder3 Folder3
Folder3
File1 Folder4 File2 Folder4
File1 Folder4
5 6
4