DHCP IP-ADDRESS For Red Hat ya Oracle Linux
systemctl restart NetworkManager
nmtui
cd /etc/sysconfig/network-scripts/
ls ifcfg-*
vi /etc/sysconfig/network-scripts/ifcfg-eth0
apt list | wc -l
dpkg -l | wc -l
Check which program is using this port
sudo lsof -i :9043
sudo netstat -tulnp | grep 9043
sudo ss -tulnp | grep 9043
sudo fuser 9043/tcp
sudo ufw allow 9090/tcp - allows firewall traffic on port 9090:
cmd - netstat and ss and
cmd - sudo ethtool enp0s3
./prometheus --web.listen-address=":9043" &
sudo ufw status
sudo ufw enable
sudo ufw allow 9043/tcp
sudo ufw allow 9043/udp
sudo ufw deny 9043/tcp
-
System Information
uname -a: Displays system information.hostname: Shows the system's hostname.uptime: Shows how long the system has been running.top: Displays real-time system processes and resource usage.htop: An enhanced version oftopwith a more user-friendly interface.dmesg: Displays kernel-related messages.free -h: Shows memory usage.
-
File System Commands
df -h: Shows disk space usage of file systems.du -sh: Displays disk usage of files and directories.ls -l: Lists files and directories with detailed information.find /path -name filename: Searches for files and directories.stat filename: Displays file or file system status.
-
Process Management
ps aux: Shows a snapshot of current processes.kill <pid>: Terminates a process by PID.pkill processname: Terminates processes by name.killall processname: Kills all processes with the given name.
-
Service Management
systemctl status service: Checks the status of a service.systemctl start service: Starts a service.systemctl stop service: Stops a service.systemctl restart service: Restarts a service.systemctl enable service: Enables a service to start on boot.systemctl disable service: Disables a service from starting on boot.
-
Network Monitoring
netstat -tuln: Displays all listening ports and their associated IP addresses.ss -tuln: Provides similar information tonetstat, often faster and more informative.ip a: Shows detailed information about network interfaces.ping host: Checks the reachability of a host.traceroute host: Displays the route packets take to a network host.mtr host: Combinespingandtraceroutefor more detailed network diagnostics.nmap -sP subnet: Scans a subnet for active devices.
-
Network Configuration
ifconfig: Configures network interfaces (older tool, replaced byip).ip link set dev interface up: Brings an interface up.ip link set dev interface down: Brings an interface down.iwconfig: Configures wireless network interfaces.
-
Network Traffic Analysis
tcpdump: Captures network traffic.wireshark: GUI-based network traffic analyzer.iftop: Displays bandwidth usage on an interface.bmon: Bandwidth monitor and rate estimator.
-
User and Group Management
useradd username: Adds a new user.usermod -aG groupname username: Adds a user to a group.passwd username: Changes a user's password.groupadd groupname: Creates a new group.groupdel groupname: Deletes a group.deluser username: Deletes a user.
-
File Permissions and Ownership
chmod 755 file: Changes file permissions.chown user:group file: Changes file ownership.
-
Security Tools
fail2ban-client status: Checks the status of fail2ban.ufw status: Checks the status of the Uncomplicated Firewall.iptables -L: Lists current firewall rules.
-
Docker
docker ps: Lists running containers.docker exec -it container /bin/bash: Opens a shell inside a running container.docker-compose up: Starts services defined indocker-compose.yml.
-
Kubernetes
kubectl get pods: Lists Kubernetes pods.kubectl describe pod podname: Shows details about a specific pod.kubectl apply -f file.yaml: Applies configuration changes from a YAML file.
-
Configuration Management
ansible-playbook playbook.yml: Runs an Ansible playbook.
-
Version Control
git status: Shows the status of a Git repository.git pull: Pulls changes from a remote repository.git push: Pushes changes to a remote repository.
-
Logs and Monitoring
tail -f /var/log/syslog: Displays the end of a log file and updates in real-time.journalctl -xe: Shows system logs.logwatch: Summarizes system logs.
-
Backup and Restore
rsync -av source destination: Synchronizes files and directories.tar -czvf archive.tar.gz /path: Creates a compressed archive of files.
-
System Updates
apt update: Updates the package index.apt upgrade: Upgrades installed packages.yum update: Updates packages on RHEL/CentOS.
-
Package Management
dpkg -l: Lists installed packages.rpm -qa: Lists all installed RPM packages.
These commands are fundamental for the daily tasks of IT professionals across various roles and are essential for effective system and network management.
Important Linux cmds for cloud Engineer check internet & Network port connection info:
- netstaat --help -
use this to know what you have requred to check - netstat -
Troubleshoot Network Issues- netstat -putan | grep :8080 -
check what is running on this port - netstat more
- netstat -at | more -
for TCP connection - netstat -au | more -
for UDP connection - netstat -atlnp | more -
check also what programm is runnig on port - netstat -r -
routing table information
- netstat -putan | grep :8080 -
-r, --route display routing table
-i, --interfaces display interface table
-g, --groups display multicast group memberships
-s, --statistics display networking statistics (like SNMP)
-M, --masquerade display masqueraded connections
-v, --verbose be verbose
-W, --wide don't truncate IP addresses
-n, --numeric don't resolve names
--numeric-hosts don't resolve host names
--numeric-ports don't resolve port names
--numeric-users don't resolve user names
-N, --symbolic resolve hardware names
-e, --extend display other/more information
-p, --programs display PID/Program name for sockets
-o, --timers display timers
-c, --continuous continuous listing
-l, --listening display listening server sockets
-a, --all display all sockets (default: connected)
-F, --fib display Forwarding Information Base (default)
-C, --cache display routing cache instead of FIB
-Z, --context display SELinux security context for socketsvmstat command ka use system performance ko monitor karne ke liye kiya jata hai. Iska full form hai "Virtual Memory Statistics." Yeh command aapko system ke various resources ki statistics provide karta hai, jaise ki memory, swap, I/O, system activity, etc. Ye information system administrators aur performance analysts ke liye bahut useful hoti hai.
- Procs: Process-related information.
r(running processes) aurb(blocked processes). - Memory: Memory usage.
swpd(swap space),free(free memory),buff(buffer memory),cache(cache memory). - Swap: Swap space statistics.
si(swap in),so(swap out). - IO: Input/Output statistics.
bi(blocks received from a block device),bo(blocks sent to a block device). - System: System-wide statistics.
in(interrupts per second),cs(context switches per second). - CPU: CPU statistics.
us(user time),sy(system time),id(idle time),wa(waiting for I/O).
Yeh command aapko system ki health aur performance ko monitor karne me madad karta hai, taaki aap timely action le sakein agar kisi resource ki utilization high hai ya koi performance issue ho raha hai.
list of commands of linux whcih use to check your system info:
# System Monitoring and Performance --------------------------------
# Real-time system processes and resource usage
top
# Interactive process viewer (requires installation)
htop
# System memory, processes, and CPU statistics
vmstat
# CPU and I/O statistics
iostat
# Displays memory usage
free -h
# Collects, reports, or saves system activity information (requires `sysstat` package)
sar -u 1 3
# Disk Usage and Management -----------------------------------
# Reports disk space usage
df -h
# Displays disk usage of files and directories
du -sh /path/to/directory
# Lists block devices
lsblk
# Partition table manipulator for Linux
sudo fdisk -l
# A more advanced partitioning tool
sudo parted /dev/sdX
# Network Configuration and Troubleshooting ----------------------------------
# Configures network interfaces (deprecated, replaced by `ip`)
ifconfig
# Shows/manages IP addresses, routes, and interfaces
ip addr show
# Tests network connectivity
ping example.com
# Traces the route packets take to a network host
traceroute example.com
# Displays network connections, routing tables, and interface statistics
netstat -tuln
# Utility to investigate sockets (more modern than `netstat`)
ss -tuln
# Queries DNS to obtain domain name or IP address mapping
nslookup example.com
# Performs DNS lookups
dig example.com
# System Services and Processes ----------------------------------------
# Manages system services and the system state
systemctl status service-name
# Manages services (deprecated in favor of `systemctl`)
service service-name status
# Displays information about active processes
ps aux
# Shows real-time system processes and resource usage
top
# File System and Disk Operations ------------------------------------------------
# Mounts file systems
mount /dev/sdXn /mnt/mountpoint
# Unmounts file systems
umount /mnt/mountpoint
# Changes file modes or Access Control Lists
chmod 755 filename
# Changes file owner and group
chown user:group filename
# Searches for files in a directory hierarchy
find /path -name filename
# Searches for patterns within files
grep 'pattern' file
# User and Group Management -----------------------------------
# Adds a new user
sudo useradd username
# Modifies a user account
sudo usermod -aG groupname username
# Changes user password
sudo passwd username
# Adds a new group
sudo groupadd groupname
# Security and Logs ---------------------------------------------------
# Uncomplicated Firewall, used to manage firewall rules
sudo ufw status
# Configures network packet filtering rules
sudo iptables -L
# Queries and displays logs from `systemd` journal
journalctl -xe
# Prints kernel ring buffer messages
dmesg | less
# Backup and Recovery ------------------------------------------------
# Synchronizes files and directories between two locations
rsync -av source/ destination/
# Archives files into tarballs
tar -czvf archive.tar.gz /path/to/directory
# Converts and copies files (useful for disk cloning)
dd if=/dev/sdX of=/path/to/backup.img bs=4M
# System Information -------------------------------------------
# Displays system information
uname -a
# Displays CPU architecture information
lscpu
# Lists block devices
lsblk
# Lists hardware information (requires installation)
sudo lshwFeel free to copy and use these commands as needed for system administration tasks.
Here's a well-organized Linux commands cheat sheet categorized into relevant sections:
- Display System Information
uname -a: Display Linux system informationuname -r: Display kernel release informationuptime: Show how long the system has been runninghostname: Show system hostnamelast reboot: Show system reboot historydate: Show the current date and timecal: Show this month's calendarw: Display who is onlinewhoami: Show who you are logged in as
- Change Permissions
chmod octal file-name: Change the permissions of a file to octal (e.g.,chmod 777 /data/test.c)chmod 755 /data/test.c: Setrwxpermission for owner,rwfor group and world
- Change Ownership
chown owner-user file: Change the owner of the filechown owner-user:owner-group file-name: Change owner and group of the filechown owner-user:owner-group directory: Change owner and group of the directory
- Network Configuration
ifconfig -a: Display all network ports and IP addressesifconfig eth0: Display specific Ethernet portethtool eth0: Show Ethernet statusmii-tool eth0: Show Ethernet status
- Network Diagnostics
ping host: Send echo request to test connectionwhois domain: Get whois information for domaindig domain: Get DNS information for domaindig -x host: Reverse lookup hostnetstat -tupl: List active connections to/from the systemwget file: Download file
- Hardware Information
dmesg: Detected hardware and boot messagescat /proc/cpuinfo: CPU modelcat /proc/meminfo: Hardware memorylshw: Display hardware configurationlsblk: Block device related informationlsusb: Show USB devicesdmidecode: Show hardware info from the BIOShdparm -i /dev/sda: Show info about disksdahdparm -t /dev/sda: Do a read speed test on disksdabadblocks -s /dev/sda: Test for unreadable blocks on disksda
- User Management
id: Show the active user ID with login and grouplast: Show last logins on the systemwho: Show who is logged on the systemuseradd "Sam Tomshi": Create userSam Tomshiuserdel sam: Delete usersamusermod: Modify user information
- File Operations
ls -al: Display all information about files/directoriespwd: Show the path of the current directorymkdir directory-name: Create a directoryrm file-name: Delete filerm -rf directory-name: Forcefully remove directory recursivelycp file1 file2: Copy file1 to file2cp -r dir1 dir2: Copy directory dir1 to dir2, create dir2 if it doesn't existmv file1 file2: Rename/move file1 to file2touch file: Create or update a filecat file: Output contents of filemore file: Output contents of file, paginghead file: Output first 10 lines of filetail file: Output last 10 lines of filetail -f file: Output contents of file as it grows
- Archive Operations
tar -cf home.tar /home: Create a tar archive namedhome.tarcontaining/home/tar -xf file.tar: Extract the files fromfile.tartar -czf file.tar.gz files: Create a tar with gzip compressiongzip file: Compress file and rename it tofile.gz
- Package Management
rpm -i pkgname.rpm: Install rpm-based packagerpm -e pkgname: Remove package
- Build from Source
./configure: Prepare the build systemmake: Compile the source codemake install: Install the compiled program
- Search Commands
grep pattern files: Search for pattern in filesgrep -r pattern dir: Search recursively for pattern in directorylocate file: Find all instances of filefind /home/tom -name "index": Find files named "index"find /home -size +10000k: Find files larger than 10000k in/home
- Transfer Files
scp file.txt user@host:/tmp: Securely copyfile.txtto remote host/tmpfolderrsync -a /home/apps/backup/ user@host:/backup/: Synchronize source to destination
- Disk Usage
df -h: Show free space on mounted filesystemsdu -ah: Show disk usage in human-readable formdu -sh: Display total disk usage on the current directoryfdisk -l: Show disk partitions sizes and types
- Process Management
ps: Display your currently active processesps aux | grep telnet: Find all process IDs related to telnetpmap: Memory map of processtop: Display all running processeskill pid: Kill process with mentioned PIDkillall process-name: Kill all processes namedprocess-namepkill process-name: Send signal to a process with its name
- Directory Navigation
cd ..: Go up one level of the directory treecd ~: Go to home directorycd /test: Change to/testdirectory
- Remote Login
ssh user@host: Connect to host as userssh -p port user@host: Connect to host using specific porttelnet host: Connect to the system using telnet
- Miscellaneous
od: Octal dumpxargs: Execute command lines from standard inputwc: Print the number of bytes, words, and lines in files
Command line tools and terminal applications for various tasks:
vmstat: Monitor system performance (alternative to be searched online)dstat: Versatile resource statistics tool
lxqt: Lightweight Qt desktop environmentXfce: Lightweight desktop environment
--help: Display help information for a commandman: Manual pages for commandsinfo: Documentation for commandshelp: Get help for built-in commands
glances: Show processes and system detailshtop: Interactive process vieweriotop: Monitor I/O usage by processesatop: Advanced system and process monitorbpytop: Resource monitoring toolnmon: Performance monitoring toolsar: Collect, report, or save system activity information
eDEX-UI: Sci-fi styled terminal emulatorhollywood: Terminal simulation with fancy visual effectssneakers: Terminal visualization toolcmatrix: Matrix-style screen saverbottom: Terminal-based resource monitormc: Midnight Commander, a text-based file managerxfce4-terminal: Lightweight terminal emulator for Xfceterminator: Terminal emulator with multiple resizable panes
asciiquarium: ASCII aquarium simulationlolcat: Add colorful effects to text outputcmatrix: Terminal screensaver with Matrix-like visualsranger: Text-based file manager with Vim-like interfaceninvaders: ASCII-based Space Invaders gamecowsay: Display text with a speech bubble from an ASCII cow
tokei: Show statistics about source codepfetch: Display system informationneofetch: Show system information with a graphical logoscreenfetch: Display system information with a logoinxi: Comprehensive system information tool
ncdu: Scan and display disk usagedu: Disk usage of files and directoriesbaobab: Disk usage analyzer with a graphical interface
tmux: Terminal multiplexer allowing multiple windowsscreen: Terminal multiplexer for managing multiple terminal sessions
ps aux: Show all running processesprocs: Process viewer with a modern interfacepstree: Show processes as a treepgrep: Look up processes based on name and other attributes
nmap: Network exploration and security auditing tooltcpdump: Network packet analyzernetcat: Network utility for reading from and writing to network connections
scp: Securely copy files between hostsrsync: Synchronize files and directories between two locationsftp: File transfer protocol client
awk: Text processing and pattern scanningsed: Stream editor for filtering and transforming textgrep: Search text using patterns
These tools cover a range of functionalities from system monitoring and management to file transfer and text processing. Feel free to explore and use them as needed!