Mastering the Ubuntu Command Line Interface (CLI)

1. Navigating the Filesystem

  • pwd: Prints the current working directory.
pwd
  • ls: Lists files and directories.
ls
  • cd: Changes the current directory.
cd /path/to/directory

2. File and Directory Operations

  • touch: Creates an empty file.
touch filename
  • mkdir: Creates a new directory.
mkdir directory_name
  • cp: Copies files or directories.
cp source_file destination
  • mv: Moves or renames files or directories.
mv source destination
  • rm: Removes files or directories.
rm filename

3. Viewing and Editing Files

  • cat: Displays the content of a file.
cat filename
  • less: Views the content of a file page by page.
less filename
  • nano: Edits files in the terminal.
nano filename

4. System Information

  • uname -a: Displays system information.
uname -a
  • df -h: Shows disk space usage.
df -h
  • top: Displays running processes.
top

5. User Management

  • whoami: Displays the current logged-in user.
whoami
  • sudo: Executes commands with superuser privileges.
sudo command

6. Package Management

  • apt update: Updates package lists.
sudo apt update
  • apt upgrade: Upgrades installed packages.
sudo apt upgrade
  • apt install: Installs a new package.
sudo apt install package_name

7. Networking

  • ifconfig: Displays network interfaces.
ifconfig
  • ping: Checks network connectivity.
ping hostname_or_ip
  • netstat: Displays network connections.
netstat

8. Disk Usage

  • du -sh: Shows disk usage of a directory.
du -sh directory_name
  • lsblk: Lists information about block devices.
lsblk

9. Searching

  • grep: Searches for patterns within files.
grep 'pattern' filename
  • find: Searches for files and directories.
find /path -name 'filename'

10. Permissions

  • chmod: Changes file permissions.
chmod permissions filename
  • chown: Changes file owner and group.
chown owner:group filename

Leave a Reply

Your email address will not be published. Required fields are marked *