Lab 2
Create a directory: mkdir
Syntax: mkdir [options] directory_name
Description: Creates a new directory.
o Create the following directory tree:
View the directory or file: ls or ll
Syntax: ls [OPTION]... [FILE]...
Description: The ls command is used to list directory contents. It displays
information about files and directories in the current directory by default, or
any specified directories.
Example:
o View the hdh directory:
o View the unix directory:
o View the windows directory:
Create a file: there are many ways to create a file
o Create the file with name thoca.txt with contents “Cong cha nhu nui thai son”
located
at 98 directory:
o Adding the “Nghia me nhu nuoc trong nguon chay ra” sentence into thoca.txt:
o Create the empty file:
View the file content: using any command as cat, more, less, tail,…
o View the thoca.txt file:
o View the /etc/passwd and /etc/group file:
Copy a file/ directory: cp
o Copy the thoca.txt file to the linux directory:
o Copy the windows directory to linux directory:
o View the linux directory:
Move objects: mv
o Move the thoca.txt file in the linux library to the openbsd library:
o Move the windows directory to penbsd directory:
Rename: mv
o Rename the windows directory in the openbsd directory to wins:
o View the openbsd directory:
o Copy the thoca.txt directory in the openbsd directory to the freebsd directory
and rename to baitho.doc
o View the baitho.doc file:
Delete a file: rm
o Delete the thoca.txt file in openbsd directory:
If wanting to delete without asking before, the option (–f) is used
o To delete the directory, the option (-rf) is used
Delete the empty directory: rmdir
o Delete the 2000 directory:
Change to the directory: cd
o Change the current directory to the 2003 directory:
o Change the current directory to sub directory: cd ..
o Change to the root directory: cd /
View the current directory: pwd
Searching: find, grep, whereis, which
o Search the thoca.txt file:
Using the wild character:
The other options can be used as: -type, -user, -atime, -amin, -newer,…
o Search the “Cong cha nhu nui thai son” sentences in the thoca.txt file
o Search the location, source and man page of the grep command:
o Search the directory that contain the ls command:
Zip or unzip: gzip/ gunzip, zip/unzip, tar
o Using gzip/gunzip:
Zip the thoca.txt file:
Unzip:
o Using tar
Zip the thoca.txt file to the .tar extension:
Checking
Zip the thoca.txt file to the .tar.gz extension:
Checking
Unzip .tar
Checking
Unzip .tar.gz