Linux commands are the backbone of system management, file handling, and process automation. This guide categorizes and summarizes essential Linux commands to help you master the terminal. Whether you’re a beginner or an advanced user, these commands will boost your productivity.

User and Permission Management

  1. sudo adduser [username]: Adds a new user to the system.
  2. sudo passwd [username]: Sets or changes the password for a user.
  3. sudo visudo: Safely edits the sudoers file to manage administrative privileges.
  4. who: Displays logged-in users.
  5. id [username]: Shows user ID and group information.
  6. chmod [permissions] [file]: Changes file permissions.
  7. chown [owner] [file]: Changes the owner of a file.

File and Directory Management

  • ls: Lists the contents of a directory.
  • ls -l: Detailed listing.
  • ls -a: Includes hidden files.
  • ls -lt: Sorts by modification time.
  • touch [filename]: Creates an empty file.
  • mkdir [dirname]: Creates a new directory.
  • mkdir -p [dir1/dir2/dir3]: Creates nested directories.
  • cp [source] [destination]: Copies files or directories.
  • cp -r: Copies directories recursively.
  • mv [source] [destination]: Moves or renames files and directories.
  • rm [filename]: Deletes a file.
  • rm -r [dirname]: Deletes a directory recursively.
  • find / -name [filename]: Searches for a file or directory.

Text Editing

  • nano [filename]: Opens the file in Nano text editor.
  • Save: Ctrl + X, Confirm: Y, Exit: Enter.
  • vi [filename]: Opens the file in Vi text editor.
  • Enter Insert Mode: i, Save: :w, Exit: :q.
  • cat [filename]: Displays the contents of a file.

System Information and Monitoring

  1. df -h: Displays disk space usage in human-readable format.
  2. du -sh [directory]: Shows the size of a file or directory.
  3. top: Monitors real-time system processes.
  4. uptime: Displays system uptime and load averages.
  5. free -h: Displays memory usage.
  6. ps aux: Lists all running processes.

Package Management

  1. sudo apt-get update: Updates the system’s package list.
  2. sudo apt-get install [package_name]: Installs a specified package.
  3. wget [URL]: Downloads files from the internet.
  4. sudo tar -xvf [filename.tar.gz]: Extracts .tar.gz files.

SSH Configuration

  • sudo vi /etc/ssh/sshd_config: Opens the SSH configuration file for editing.
  • Enable password login: PasswordAuthentication yes.
  1. Restart SSH service:
  • sudo service ssh restart
  • sudo service ssh start
  • sudo service ssh stop

Disk and Filesystem Operations

  1. mount [device] [directory]: Mounts a filesystem.
  2. umount [directory]: Unmounts a filesystem.
  3. lsblk: Lists information about block devices.
  4. blkid: Displays UUIDs of filesystems.
  5. df -h: Checks available disk space.

Networking

  1. ping [host]: Sends ICMP packets to test connectivity.
  2. ifconfig / ip addr: Displays or configures network interfaces.
  3. netstat -tuln: Displays active network connections.
  4. curl [URL]: Fetches content from a URL.

Miscellaneous Commands

  1. history: Displays a list of previously executed commands.
  2. clear: Clears the terminal screen.
  3. pwd: Displays the current working directory.
  4. echo [text]: Prints text to the terminal.
  5. alias [name]='[command]': Creates a shortcut for a command.

Advanced Tips

  1. Shortcuts:
  • Ctrl + C: Stops a running process.
  • Ctrl + Z: Pauses a process.
  • Ctrl + D: Logs out of the terminal.
  1. Wildcards:
  • *: Matches multiple characters.
  • ?: Matches a single character.
  1. Chaining Commands:
  • command1 && command2: Runs the second command only if the first succeeds.
  • command1 || command2: Runs the second command if the first fails.

Conclusion

Mastering Linux commands is crucial for anyone working with servers, development, or system administration. This categorized list will serve as a solid reference. Whether you’re managing users, files, or processes, these commands provide the tools to accomplish your tasks efficiently. Bookmark this guide and keep practicing to enhance your Linux expertise!

Similar Posts

Leave a Reply

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