COMMANDS FLASH CARDS

4.04 Identify common features and tools of Linux client and desktop OS

  • Command: ‘ls’

  • Lists the contents of a directory.

  • What are common options used with the “ls” Command?

  • ‘ls -l’ Long format (detailed information).

  • ‘ls -a’ Shows all files, including hidden files.

  • Command: ‘cd’

  • Changes the current directory.

  • 'cd /etc’ Changes to the ‘/etc’ directory.

  • 'cd ..’ Moves up one directory level.

  • Command: ‘pwd’

  • Prints the current working directory.

  • `pwd`: Displays the full path of the current directory.

  • Command: `mkdir`

  • Creates a new directory.

  • Examples: `mkdir new_folder`

  • Creates a directory named `new_folder`.

  • Command: `rm`

  • Removes files or directories.

  • Options: `-r`: Recursively deletes a directory and its contents. `-f`: Forces deletion without prompting.

  • Examples: `rm file.txt`: Deletes `file.txt`.

  • `rm -rf directory_name`: Deletes a directory and all its contents.

  • Command: `cp`

  • Copies files or directories.

  • Options: `-r`: Recursively copies directories and their contents.

  • Examples:** `cp file.txt /destination_folder/`: Copies `file.txt` to `/destination_folder/`.

  • `cp -r source_folder/ destination_folder/`: Copies `source_folder` and its contents to `destination_folder`.

  • Command: `mv`

  • Moves or renames files and directories.

  • Examples: `mv old_name.txt new_name.txt`: Renames a file.

  • `mv file.txt /destination_folder/`: Moves `file.txt` to another directory.

  • Command: `touch`

  • Creates an empty file or updates the timestamp of an existing file.

  • Example: `touch newfile.txt`: Creates an empty file named `newfile.txt`.

  • Command: `cat`

  • Concatenates (links) and displays the content of files.

  • Example: `cat file.txt`: Displays the contents of `file.txt`.

  • Command: `echo`

  • Displays a line of text or variable value.

  • Example: `echo "Hello, World!"`: Prints "Hello, World!" to the terminal.

  • Command: `grep`

  • Searches for patterns within files.

  • Options: `-i`: Case-insensitive search. `-r`: Searches recursively through directories.

  • Example: `grep "search_term" file.txt`: Searches for "search_term" in `file.txt`.

  • Command: `man`

  • Displays the manual page for a command.

  • Example: `man ls`: Shows the manual for the `ls` command.

  • Command: `chmod`

  • Changes the file or directory permissions.

  • Examples: `chmod 755 file.txt`: Sets read, write, execute permissions for the owner and read, execute for others.

  • Command: `chown`

  • Changes the owner and group of a file or directory.

  • Example: `chown user:group file.txt`: Changes the owner to `user` and the group to `group`.

  • Command: `su'

  • Switches to a different user.

  • Command: `sudo`

  • Executes a command with superuser (root) privileges.

  • Example: `sudo apt update`: Runs the `apt update` command with elevated privileges.

  • Command: `apt` or `yum`

  • Package management commands for installing, updating, and removing software.

  • Examples: `apt install package_name`: Installs a package on Debian-based systems.

  • `yum install package_name`: Installs a package on Red Hat-based systems.

  • Command: `df`

  • Displays disk space usage.

  • Options: `-h`: Human-readable format (e.g., KB, MB).

  • Example: `df -h`: Shows disk usage in a human-readable format.

  • Command: `du`

  • Shows disk usage of files and directories.

  • Options: `-h`: Human-readable format. `-s`: Summarizes disk usage.

  • Example: `du -sh *`: Displays disk usage of all items in the current directory.

  • Command: `top`

  • Displays active processes and resource usage in real-time.

  • Usage: Type `top` and press ENTER to view real-time processes and their resource usage.

  • Command: `kill`

  • Terminates a process by its process ID (PID).

  • Examples: `kill 1234`: Kills the process with PID 1234.

  • `kill -9 1234`: Forcefully kills the process with PID 1234.