0% found this document useful (0 votes)
122 views7 pages

Devops Shack: Linux Commands Documentation

Uploaded by

ANIL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views7 pages

Devops Shack: Linux Commands Documentation

Uploaded by

ANIL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DevOps Shack

Linux Commands Documentation.


Click Here To Enrol To Batch-5 | DevOps & Cloud DevOps

1. Introduction to Linux
Linux is an open-source operating system that manages hardware and software
resources on a computer. It provides a user interface and a range of utilities to
perform system tasks.

2. Basic Linux Commands


These commands are fundamental and are used to perform basic operations.

• pwd: Print Working Directory


pwd
• ls: List directory contents
• ls
• ls -l # long format
ls -a # all files including hidden
• cd: Change Directory
• cd /path/to/directory
• cd ~ # home directory
cd .. # parent directory

3. File Management Commands


These commands help in creating, deleting, copying, and moving files.

• touch: Create an empty file


touch filename
• cp: Copy files or directories
• cp source destination
cp -r source_directory destination_directory
• mv: Move or rename files or directories
• mv old_name new_name
mv source destination
• rm: Remove files or directories
• rm filename
rm -r directory_name

4. Text Processing Commands


These commands are used to manipulate text files.

• cat: Concatenate and display file content


cat filename
• grep: Search text using patterns
grep "pattern" filename
• sed: Stream editor for filtering and transforming text
sed 's/old/new/g' filename
• awk: Pattern scanning and processing language
awk '{print $1}' filename

5. User Management Commands


Manage users and groups on the system.

• adduser: Add a new user


sudo adduser username
• deluser: Delete a user
sudo deluser username
• usermod: Modify a user
sudo usermod -aG groupname username

6. Network Commands
Commands to manage and troubleshoot network settings.

• ifconfig: Configure a network interface


ifconfig
• ping: Send ICMP ECHO_REQUEST to network hosts
ping google.com
• netstat: Network statistics
netstat -an
• ssh: Secure Shell
ssh user@hostname

7. System Monitoring Commands


Monitor system performance and status.
• top: Display Linux tasks
top
• htop: Interactive process viewer
htop
• ps: Report a snapshot of current processes
ps aux
• df: Report file system disk space usage
df -h
• du: Estimate file space usage
du -sh directory_name

8. Package Management Commands


Manage software packages.

• apt-get: APT package handling utility (Debian-based)


• sudo apt-get update
• sudo apt-get install package_name
sudo apt-get remove package_name
• yum: Package manager (RHEL-based)
• sudo yum update
• sudo yum install package_name
sudo yum remove package_name

9. Disk Management Commands


Commands to manage disk partitions and usage.

• fdisk: Partition table manipulator


sudo fdisk -l
• mkfs: Build a Linux file system
sudo mkfs.ext4 /dev/sdX1
• mount: Mount a file system
sudo mount /dev/sdX1 /mnt
• umount: Unmount file system
sudo umount /mnt

10. Shell Scripting Basics


Automate tasks using shell scripts.

• Creating a simple script

• #!/bin/bash
echo "Hello, World!"

• Running a script

• chmod +x script_name.sh
./script_name.sh

• Variables

• name="John"
echo "Hello, $name"

• Conditional Statements

• if [ condition ]
• then
• # commands
fi

• Loops

• for i in {1..5}
• do
• echo "Iteration $i"
done

11. Advanced File Management


Commands for advanced file and directory manipulation.

• find: Search for files in a directory hierarchy


• find /path/to/search -name "filename"
find /path/to/search -type f -size +100M
• locate: Find files by name
locate filename
• ln: Create links between files
ln -s /path/to/original /path/to/symlink
• tar: Archive files
• tar -cvf archive.tar /path/to/directory
• tar -xvf archive.tar
• tar -czvf archive.tar.gz /path/to/directory
tar -xzvf archive.tar.gz
• zip and unzip: Compress and decompress files
• zip archive.zip filename
unzip archive.zip

12. Process Management


Commands to manage running processes.

• kill: Terminate a process by PID


kill PID
• killall: Terminate all processes by name
killall process_name
• pkill: Kill processes by name
pkill process_name
• bg: Resume a suspended job in the background
bg %job_number
• fg: Resume a job in the foreground
fg %job_number
• nohup: Run a command immune to hangups
nohup command &

13. Permission Management


Commands to manage file and directory permissions.

• chmod: Change file mode (permissions)


• chmod 755 filename
chmod u+x filename
• chown: Change file owner and group
sudo chown owner:group filename
• chgrp: Change group ownership
sudo chgrp group filename

14. Disk Quotas


Commands to manage disk quotas.

• quota: Display disk usage and limits


quota -u username
• edquota: Edit user quotas
sudo edquota -u username
• repquota: Report on disk quotas
sudo repquota /filesystem

15. Backup and Restore


Commands to perform system backups and restores.

• rsync: Remote file and directory synchronization


• rsync -av /source/directory /destination/directory
rsync -avz /source/directory user@remote:/destination/directory
• dd: Convert and copy a file
• dd if=/dev/sdX of=/path/to/backup.img
dd if=/path/to/backup.img of=/dev/sdX

16. System Maintenance


Commands to perform system maintenance tasks.

• fsck: File system consistency check and repair


sudo fsck /dev/sdX
• tune2fs: Adjust tunable file system parameters
sudo tune2fs -l /dev/sdX
• e2fsck: Check a Linux ext2/ext3/ext4 file system
sudo e2fsck /dev/sdX

17. Kernel Management


Commands to manage the Linux kernel.

• uname: Print system information


uname -a
• dmesg: Print or control the kernel ring buffer
dmesg | less
• modprobe: Add and remove modules from the Linux kernel
• sudo modprobe module_name
sudo modprobe -r module_name

18. Security Management


Commands to enhance system security.

• ufw: Uncomplicated Firewall


• sudo ufw enable
• sudo ufw status
sudo ufw allow from 192.168.1.0/24
• iptables: Administration tool for IPv4 packet filtering
• sudo iptables -L
• sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

19. Advanced Text Processing


Further text processing commands for advanced users.

• tr: Translate or delete characters


echo "hello" | tr 'a-z' 'A-Z'
• sort: Sort lines of text files
sort filename
• uniq: Report or omit repeated lines
uniq filename
• wc: Print newline, word, and byte counts for each file
wc filename
20. Miscellaneous Commands
Various useful commands for different tasks.

• alias: Create an alias for a command


alias ll='ls -la'
• uptime: Tell how long the system has been running
uptime
• who: Show who is logged on
who
• date: Display or set the system date and time
date
• cal: Display a calendar
cal
• history: Display the command history
history

You might also like