๐Ÿง Linux Command Line Basics: A Comprehensive Guide for DevOps Engineers! ๐Ÿš€

ยท

2 min read

1. Navigating the File System ๐Ÿ“‚

  • pwd: Check the present working directory.

  • ls: List files and directories in the current folder.

  • cd: Change directory. Use cd .. to go up one level.

  • mkdir: Create a new directory.

  • rmdir: Remove an empty directory.

  • touch: Create an empty file.

๐Ÿ”‘ Tip: Use cd - to switch to the previous directory.

2. Managing Files and Directories ๐Ÿ—‚๏ธ

  • cp: Copy files or directories.

  • mv: Move or rename files or directories.

  • rm: Remove files or directories. Use with caution (rm -r for directories).

  • cat: Concatenate and display file contents.

  • less: View file contents page by page.

๐Ÿ”‘ Tip: To delete files interactively, use rm -i.

3. File Permissions ๐Ÿ”’

  • chmod: Change file permissions. E.g., chmod u+x filename grants the owner execute permission.

๐Ÿ”‘ Tip: Use ls -l to view permissions for files and directories.

4. Working with Users ๐Ÿ‘ค

  • who: Display users currently logged in.

  • useradd: Add a new user.

  • userdel: Delete a user.

๐Ÿ”‘ Tip: Use sudo to execute commands with administrator privileges.

5. Process Management โš™๏ธ

  • ps: View running processes.

  • top: Monitor system processes in real-time.

  • kill: Terminate processes. Use with caution.

๐Ÿ”‘ Tip: For a friendlier process viewer, try htop.

6. Redirection and Pipelines ๐Ÿšฐ

  • >: Redirect output to a file.

  • >>: Append output to a file.

  • |: Create a pipeline to send output of one command as input to another.

๐Ÿ”‘ Tip: Use grep to search for specific patterns in files or command outputs.

7. Disk Usage ๐Ÿ’พ

  • df: Display disk space usage of file systems.

  • du: Estimate file and directory space usage.

๐Ÿ”‘ Tip: Combine du with sort to find the largest files on your system.

8. Network Tools ๐ŸŒ

  • ping: Check network connectivity.

  • ifconfig / ip: Display network interface information.

  • ssh: Securely connect to remote systems.

๐Ÿ”‘ Tip: For a graphical interface, use nmtui to manage network connections.

9. Finding Files ๐Ÿ”

  • find: Search for files and directories.

  • locate: Quickly find files using a pre-built database.

๐Ÿ”‘ Tip: Update the locate database with sudo updatedb.

10. Getting Help โ“

  • man: Display manual pages for commands.

  • --help: Many commands support this option to show help.

๐Ÿ”‘ Tip: Use apropos to search for commands based on keywords.

DevOps engineers often work extensively with the Linux command line to manage servers, automate deployments, and orchestrate systems efficiently. By mastering these essential commands, DevOps professionals can streamline their workflows and drive innovation in their organizations.

Happy Linuxing! ๐ŸŽ‰

ย