Day 12 of #90DaysOfDevOps
Table of contents
Linux Git Cheat Sheet
File System Navigation:
sudo
- Super User Do. The sudo command allows you to run commands with the superuser privileges.whoami
- Displays currently logged-in user.pwd
: Print the current working directory.ls
: List files and directories in the current directory.ls -l
: List files and directories in long format.ls -a
: List all files and directories, including hidden ones.
cd
: Change the current directory.cd ~
: Change to the home directory.cd ..
: Move up one directory level.
touch
: Create an empty file.mkdir
: Create a new directory.rm
: Remove files or directories.rm -r
: Remove directories recursively.
mv
: Move or rename files and directories.cp
: Copy files and directories.find
: Search for files and directories.grep
: Search for text within files.cat
: Display the contents of a file.echo
- displaying lines of text or string which are passed as arguments on the command line. Can be used to create a file or empty a file.echo "Hello"
- prints Helloecho "Hello" > hello.txt
- Creates a file hello.txt with Hello as content in it.echo "World" >> hello.txt
- appends the content(World) to the file hello.txtecho > hello.txt
- Empties the content from hello.txt file.stat
- Display file or file system status.more
orless
: View file content page by page.head
andtail
: Display the beginning or end of a file.sort
- The sort command sorts the contents of a file, in numeric or alphabetic order, and prints the results to standard output.-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)
-n, --numeric-sort compare according to string numerical value
-r, --reverse reverse the result of comparisons
file
: Determine file type.
File Permissions:
chmod
: Change file permissions.chown
: Change file ownership.chgrp
: Change group ownership.umask
: Set default permissions for new files and directories.
ACL file permissions:
getfacl
- Get file ACL. This command shows the permission of the file in detailed manner.setfacl
- set file permission using ACL.setfacl -m u:jack:r-- test.txt
-m - modify, u-user, jack-username, r---read permission, test.txt- file name
setfacl -x u:jack:r test.txt
To remove permission for a file from all the user and groups which were added using ACL.
Process Management:
ps
: List running processes.ps aux
: List all processes.
top
: Monitor system processes in real-time.kill
: Terminate processes.killall
: Terminate processes by name.bg
andfg
: Manage background and foreground processes.nohup
: Run a command that continues running even after you log out.
Package Management (Debian/Ubuntu):
apt-get update
: Update package lists.apt-get upgrade
: Upgrade installed packages.apt-get install
: Install new packages.apt-get remove
: Remove packages.apt-cache search
: Search for packages.dpkg
: Debian package management commands.
Package Management (Red Hat/CentOS):
yum update
: Update packages.yum install
: Install packages.yum remove
: Remove packages.yum search
: Search for packages.rpm
: RPM package management commands.
Networking:
ifconfig
orip
: Display network interface information.ping
: Check network connectivity.netstat
: Network statistics.ssh
: Securely access remote systems.scp
: Securely copy files between systems.curl
orwget
: Download files from the internet.nc
: Netcat for network-related tasks.iptables
orfirewalld
: Configure firewall rules.
System Information:
uname
: Display system information.df
: Show disk space usage.du
: Show directory space usage.free
: Display memory usage.top
orhtop
: Monitor system resources.lscpu
orcat /proc/cpuinfo
: CPU information.lsblk
orfdisk -l
: List block devices.date
: Display the system date and time.
Shell Scripting:
Create and edit shell scripts using a text editor like
nano
,vim
, oremacs
.Use
#!/bin/bash
(or another shell) as the shebang line.Make the script executable with
chmod +x script.sh
.Execute the script with
./script.sh
orbash script.sh
Automation (cron):
crontab
: Schedule recurring tasks.
Text Processing:
sed
: Stream editor for text manipulation.awk
: Text processing tool.cut
: Extract sections from lines of files.
Monitoring and Logging:
- Use tools like
syslog
,journalctl
, andlogrotate
for system logs.
Subscribe to my newsletter
Read articles from Basavaraj Teli directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Basavaraj Teli
Basavaraj Teli
Aspiring DevOps engineer, working on DevOps projects to gain practical knowledge. I write technical blog post on DevOps to share my knowledge with fellow tech enthusiasts.