Basic Commands in Unix/Linux: ls
, cd
, pwd
, and more
1. ls
: List Directory Contents
The ls
command is used to list the contents of a directory. By default, it lists the contents of the current directory.
Syntax:
ls [options] [directory]
Common Options:
-l
: Long listing format (includes file permissions, number of links, owner, group, size, and timestamp)-a
: Show all files, including hidden ones (those starting with a dot)-h
: Human-readable format (for sizes, e.g., KB, MB)
Example:
ls -lah
2. cd
: Change Directory
The cd
command allows you to navigate between directories.
Syntax:
cd [directory]
Examples:
- To move to a subdirectory:
cd subdirectory_name
cd ..
cd ~
3. pwd
: Print Working Directory
The pwd
command prints the full path of the current working directory.
Syntax:
pwd
Example:
pwd
4. mkdir
: Make Directory
The mkdir
command creates a new directory.
Syntax:
mkdir [options] directory_name
Common Options:
-p
: Create parent directories as needed
Example:
mkdir -p parent_directory/subdirectory
5. rmdir
: Remove Directory
The rmdir
command removes an empty directory.
Syntax:
rmdir [directory]
Example:
rmdir empty_directory
6. rm
: Remove Files or Directories
The rm
command is used to remove files or directories.
Syntax:
rm [options] file_or_directory
Common Options:
-r
: Remove directories and their contents recursively-f
: Force removal without prompting for confirmation
Example:
rm -rf directory_to_remove
Comments
Post a Comment