Command for lab practice for information technology
1. Working with Commands
These are the essential command-line concepts and
commands for working with directories in
Ubuntu/Linux. Mastering these skills will allow you to
navigate, manage, and automate your file system
efficiently from the command line.
The command prompt, often represented by $, is
where you enter commands.
It typically displays the current working directory and
user information.
1
2. 2
Creating and Deleting Directories:
•mkdir directory_name: Create a new
directory with the specified name.
•nano directory_name.txt: Create a new text
with the specified name.
•rmdir directory_name: Delete an empty
directory.
•rm -r directory_name: Delete a directory and
all its contents recursively.
Navigating Directories:
•cd directory_name: Change the current working
directory to the specified directory.
•cd ..: Move up one directory (to the parent
directory).
•cd ~: Move to the home directory.
•pwd: Print the current working directory.
3. 3
Listing Directory Contents:
•ls: List files and directories in the current working
directory.
•ls -l: List in long format, showing permissions, owner,
group, size, and modification date.
•ls -a: List all files, including hidden files (starting with a
dot).
•ls -R: List files and directories recursively, showing the
contents of subdirectories.
•ls -t: Sort the listing by modification time, with the most
recent files first.
•ls -S: Sort the listing by file size, with the largest files
first.
4. 4
Advanced Listing Options:
•ls -lR: List files and directories recursively in long format.
•ls -lrt: List files and directories sorted by modification
time, newest first.
•ls -lS: List files and directories sorted by size, largest first.
•ls -lh: List file sizes in human-readable format (KB, MB, GB).
•ls -ld */: List only subdirectories in the current directory.