11 Lab Manual Working With Files and Directories
11 Lab Manual Working With Files and Directories
3. click on the black box icon (Terminal Emulator) in the top left corner of the Kali
Linux Desktop.
1
Running the terminal while using the root account, allows you to run various
commands with administrator rights.
2
d) Display File Size In Human Readable Format using
ls -lh
2. CAT COMMAND
The cat command is a utility command in Linux. One of its most common
usages is to print the content of a file onto the standard output stream.
Other than that, the cat command also allows us to write some texts into a
file.
a) To view Single File
cat newfile.txt
3
d) Create a file
Cat createfile
3. TOUCH COMMAND
The touch command's primary function is to modify a timestamp.
Commonly, the utility is used for file creation, although this is not its primary
function. The terminal program can change the modification and access time
for any given file. The touch command creates a file only if the file doesn't
already exist.
a) To Create File only
touch createfile
4
c) To change file Modification time only
touch -m
4. MKDIR COMMAND
The mkdir command in Linux/Unix allows users to create or make new
directories. mkdir stands for “make directory.” With mkdir, you can also set
permissions, create multiple directories (folders) at once, and much more
a) To Create Single Directory
Mkdir directory name
5
b) To Create Multiple Directories
Mkdir -p directory name
5. RM COMMAND
Use the rm command to remove files you no longer need. The rm
command removes the entries for a specified file, group of files, or certain
select files from a list within a directory. User confirmation, read permission,
and write permission are not required before a file is removed when you use
the rm command.
a) To remove file
rm filename
6
b) To recursively delete a directory and all its contents
rm -r
6. CP COMMAND
You can use the cp command for copying files from one location to another.
This command can also copy directories (folders). [file/directory-sources]
specifies the sources of the files or directories you want to copy. And the
[destination] argument specifies the location you want to copy the file to.
7. MV COMMAND
Use the mv command to move files and directories from one directory to
another or to rename a file or directory.
8
mv c.txt d.txt