Linux Commands To Practice
Linux Commands To Practice
`ls`
**Description:** Lists directory contents.
**Examples:**
- `ls` - Lists files and directories in the current directory.
- `ls -l` - Lists files and directories in long format.
### 2. `cd`
**Description:** Changes the current directory.
**Examples:**
- `cd /home/user` - Changes to the `/home/user` directory.
- `cd ..` - Moves up one directory level.
### 3. `pwd`
**Description:** Prints the current working directory.
**Examples:**
- `pwd` - Shows the full path of the current directory.
- `pwd -P` - Shows the physical directory, without symbolic links.
### 4. `cp`
**Description:** Copies files or directories.
**Examples:**
- `cp file1.txt file2.txt` - Copies `file1.txt` to `file2.txt`.
- `cp -r dir1 dir2` - Recursively copies `dir1` to `dir2`.
### 5. `mv`
**Description:** Moves or renames files or directories.
**Examples:**
- `mv file1.txt file2.txt` - Renames `file1.txt` to `file2.txt`.
- `mv dir1 /home/user/` - Moves `dir1` to `/home/user/`.
### 6. `rm`
**Description:** Removes files or directories.
**Examples:**
- `rm file1.txt` - Removes `file1.txt`.
- `rm -r dir1` - Recursively removes `dir1` and its contents.
### 7. `touch`
**Description:** Creates an empty file or updates the timestamp of an existing file.
**Examples:**
- `touch file1.txt` - Creates `file1.txt` if it doesn't exist.
- `touch -a -m file1.txt` - Updates access and modification times of `file1.txt`.
### 8. `mkdir`
**Description:** Creates a directory.
**Examples:**
- `mkdir newdir` - Creates a directory named `newdir`.
- `mkdir -p /path/to/dir` - Creates a directory with all intermediate directories.
### 9. `rmdir`
**Description:** Removes an empty directory.
**Examples:**
- `rmdir olddir` - Removes the directory named `olddir`.
- `rmdir --ignore-fail-on-non-empty dir1` - Removes `dir1` if it is empty, ignoring errors if it
is not.