๐ง Linux Command Line Basics: A Comprehensive Guide for DevOps Engineers! ๐
1. Navigating the File System ๐
pwd
: Check the present working directory.ls
: List files and directories in the current folder.cd
: Change directory. Usecd ..
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! ๐