100DaysOfDataEngineering Day 6,7,8 Linux
commonly used Linux commands grouped by categories.
File Management
- ls: Lists files and directories.
- Example:
ls -al
(lists all files/directories with details)
- Example:
- cd: Changes the current working directory.
- Example:
cd /home/username/Documents
- Example:
- mkdir: Creates a new directory.
- Example:
mkdir project_folder
- Example:
- rmdir: Removes empty directories.
- Example:
rmdir empty_directory
- Example:
- touch: Creates an empty file or updates an existing file’s timestamp.
- Example:
touch new_file.txt
- Example:
- cp: Copies files and directories.
- Exmaple:
cp important_report.doc backup_folder
- Exmaple:
- mv: Moves or renames files and directories.
- Example:
mv old_name.txt new_name.txt
- Example:
- rm: Deletes files and directories.
- Example
rm unwanted_file.log
- Example
Text Manipulation
- cat: Concatenates and displays file contents.
- Example:
cat todo.txt
- Example:
- less: Efficiently displays large files, allowing scrolling.
- Example:
less very_long_report.csv
- Example:
- head: Displays the initial lines of a file.
- Example:
head -n 10 access.log
- Example:
- tail: Displays the last lines of a file.
- Example:
tail -f error.log
(monitors errors in real-time)
- Example:
- grep: Searches for patterns within files.
- Example:
grep "warning" system_log.txt
- Example:
System Information and Management
df
– Display disk space usage- Example:
df -h
shows disk space in human-readable format
- Example:
du
– Estimate file space usage- Example:
du -h
shows directory space usage in human-readable format
- Example:
top
– Task manager- Example:
top
shows real-time information about running processes
- Example:
ps
– Process status- Example:
ps -aux
shows all running processes
- Example:
kill
– Kill a process- Example:
kill 1234
terminates the process with PID 1234
- Example:
File Archiving and Transfer
tar
– Archive files- Example:
tar -cvf archive.tar /dir
creates an archive of/dir
- Example:
gzip
– Compress files- Example:
gzip file.txt
compressesfile.txt
tofile.txt.gz
- Example:
scp
– Secure copy- Example:
scp file.txt user@host:/path
copiesfile.txt
to the remote directory
- Example:
wget
– Network downloader- Example:
wget http://example.com/file.txt
downloadsfile.txt
from the web
- Example:
curl
– Transfer data from or to a server- Example:
curl http://example.com
fetches the content of the specified URL
- Example:
Network and Connectivity
ping
– Check connectivity to a host- Example:
ping google.com
checks connectivity togoogle.com
- Example:
netstat
– Network statistics- Example:
netstat -tuln
lists active network connections
- Example:
ifconfig
– Configure network interface- Example:
ifconfig eth0
displays configuration ofeth0
interface
- Example:
ip
– Show/manipulate routing, network devices- Example:
ip addr show
lists IP addresses and network interfaces
- Example:
ssh
– Secure Shell client- Example:
ssh user@host
connects tohost
asuser
- Example:
System Administration and Maintenance
sudo
– Execute a command as another user- Example:
sudo apt update
runsapt update
as superuser
- Example:
passwd
– Change user password- Example:
passwd
changes the current user’s password
- Example:
chown
– Change file owner and group- Example:
chown user:group file.txt
changes the owner offile.txt
touser
- Example:
chmod
– Change file access permissions- Example:
chmod 755 file.txt
setsfile.txt
permissions to 755
- Example:
mount
– Mount a filesystem- Example:
mount /dev/sda1 /mnt
mounts/dev/sda1
to/mnt
- Example:
Process and Job Control
bg
– Move a job to the background- Example:
bg
moves the current job to the background
- Example:
fg
– Move a job to the foreground- Example:
fg
brings the most recent background job to the foreground
33.
jobs
– List active jobs- Example:
jobs
lists currently active jobs
- Example:
nohup
– Run a command immune to hangups- Example:
nohup command &
runscommand
immune to hangups
- Example:
screen
– Multiplex terminal, manage multiple sessions- Example:
screen -S session_name
starts a new session namedsession_name
- Example:
Package Management
apt
,yum
,dnf
– Package management commands (Debian/Ubuntu, RedHat/CentOS, Fedora)- Example:
apt install nginx
installs nginx on Debian/Ubuntu systems
- Example:
dpkg
– Debian package manager- Example:
dpkg -l
lists installed packages on Debian/Ubuntu
- Example:
Text Processing
awk
– Pattern scanning and processing language- Example:
awk '{print $1}' file.txt
prints the first column offile.txt
- Example:
sed
– Stream editor- Example:
sed 's/old/new/' file.txt
replaces ‘old’ with ‘new’ infile.txt
- Example:
sort
– Sort text files- Example:
sort file.txt
sorts the contents offile.txt
alphabetically
- Example:
System Services
systemctl
– Control the systemd system and service manager- Example:
systemctl start nginx
starts the nginx service
- Example:
service
– Manage System V init services- Example:
service nginx start
starts the nginx service
- Example:
Monitoring and Debugging
dmesg
– Print kernel ring buffer- Example:
dmesg
displays messages from the kernel ring buffer
- Example:
journalctl
– Query the systemd journal- Example:
journalctl -u nginx
shows journal entries for the nginx service
- Example:
htop
– Interactive process viewer- Example:
htop
shows an interactive view of running processes
- Example:
File Systems and Storage
fdisk
– Disk partitioning tool- Example:
fdisk /dev/sda
edits the partition table for/dev/sda
- Example:
dd
– Convert and copy a file- Example:
dd if=/dev/sda of=/dev/sdb
copies/dev/sda
to/dev/sdb
- Example:
lsblk
– List block devices- Example:
lsblk
lists all block storage devices
- Example:
Miscellaneous Commands
echo
– Display a line of text- Example:
echo "Hello World"
printsHello World
- Example:
history
– Command history- Example:
history
shows the command history
- Example:
This list covers a broad spectrum of frequently used Linux commands, essential for various tasks in system administration, file manipulation, networking, and more. Each command serves a specific purpose, helping users to manage and interact with the system effectively.