0% found this document useful (0 votes)
25 views8 pages

Linux Command

The document provides a comprehensive list of Linux commands organized into various categories including File and Directory Management, Process Management, Disk Management, Networking, User and Group Management, and more. Each command is accompanied by a brief description of its functionality, making it a useful reference for users seeking to understand or utilize Linux commands effectively. Additionally, it covers advanced topics such as system diagnostics, file permissions, and containerization with Docker.

Uploaded by

Khushi Lodhi
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)
25 views8 pages

Linux Command

The document provides a comprehensive list of Linux commands organized into various categories including File and Directory Management, Process Management, Disk Management, Networking, User and Group Management, and more. Each command is accompanied by a brief description of its functionality, making it a useful reference for users seeking to understand or utilize Linux commands effectively. Additionally, it covers advanced topics such as system diagnostics, file permissions, and containerization with Docker.

Uploaded by

Khushi Lodhi
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/ 8

1.

File and Directory Management  uniq – Report or omit repeated lines

 ls – List directory contents 3. Process Management


 cd – Change directory
 pwd – Print working directory  ps – Report a snapshot of current processes
 cp – Copy files and directories  top – Display Linux tasks
 mv – Move or rename files and directories  htop – Interactive process viewer (advanced top)
 rm – Remove files or directories  kill – Send a signal to a process, typically to terminate
 mkdir – Make directories  killall – Terminate processes by name
 rmdir – Remove empty directories  bg – Resume a suspended job in the background
 touch – Change file timestamps or create empty files  fg – Bring a job to the foreground
 find – Search for files in a directory hierarchy  jobs – List active jobs
 locate – Find files by name  nice – Run a program with modified scheduling priority
 tree – Display directories in a tree-like format  renice – Alter priority of running processes
 chmod – Change file permissions  uptime – Show how long the system has been running
 chown – Change file owner and group  time – Measure program running time
 chgrp – Change group ownership
 stat – Display file or file system status
4. Disk Management
 df – Report file system disk space usage
2. File Viewing and Editing  du – Estimate file space usage
 cat – Concatenate and display file content  fdisk – Partition table manipulator for Linux
 tac – Concatenate and display file content in reverse  lsblk – List information about block devices
 more – View file content interactively (page by page)  mount – Mount a file system
 less – View file content interactively (scrollable)  umount – Unmount a file system
 head – Output the first part of a file  parted – A partition manipulation program
 tail – Output the last part of a file  mkfs – Create a file system
 nano – Text editor (terminal-based)  fsck – File system consistency check and repair
 vim / vi – Advanced text editors  blkid – Locate/print block device attributes
 emacs – Text editor
 grep – Search text using patterns
5. Networking
 sed – Stream editor for filtering and transforming text  ifconfig – Configure network interfaces
 awk – Pattern scanning and processing language  ip – Show/manipulate routing, devices, and tunnels
 cut – Remove sections from each line of files  ping – Send ICMP Echo requests to network hosts
 sort – Sort lines of text files
Page | 1 Page | 2
 netstat – Network statistics  lscpu – Display information about the CPU architecture
 ss – Socket statistics (faster than netstat)  lsusb – List USB devices
 traceroute – Trace the route packets take to a network host  lspci – List PCI devices
 nslookup – Query Internet name servers interactively  lshw – List hardware configuration
 dig – DNS lookup utility
 wget – Non-interactive network downloader 8. Archiving and Compression
 curl – Transfer data with URLs
 scp – Secure copy files between hosts  tar – Archive files
o tar -czf archive.tar.gz /path/to/directory – Compress files
 ssh – Secure shell for remote login
 ftp – File Transfer Protocol client using gzip
o tar -xzf archive.tar.gz – Extract gzipped tarball

o tar -cf archive.tar /path/to/directory – Create a tarball


6. User and Group Management
o tar -xf archive.tar – Extract tarball

 useradd – Add a user to the system  zip – Package and compress files into a ZIP archive
 usermod – Modify a user account  unzip – Extract files from a ZIP archive
 userdel – Delete a user account  gzip – Compress files using the gzip algorithm
 groupadd – Add a group to the system  gunzip – Decompress files compressed with gzip
 groupdel – Delete a group  bzip2 – Compress files using the bzip2 algorithm
 passwd – Change user password  bunzip2 – Decompress files compressed with bzip2
 chage – Change user password expiry information  xz – Compress files using the xz algorithm
 whoami – Print the current logged-in user  unxz – Decompress files compressed with xz
 who – Show who is logged in
 w – Show who is logged in and what they’re doing 9. Package Management (Depends on Distribution)
 id – Display user and group information
 groups – Show user’s groups Debian-based (e.g., Ubuntu)

 apt-get – APT package handling utility


7. System Information and Monitoring o apt-get install <package> – Install a package

o apt-get update – Update package list


 uname – Print system information
o apt-get upgrade – Upgrade installed packages
 hostname – Show or set the system’s hostname
o apt-get remove <package> – Remove a package
 uptime – How long the system has been running
 dmesg – Boot and system messages  apt-cache – Query APT cache
o apt-cache search <package> – Search for a package
 free – Display memory usage
o apt-cache show <package> – Show package details
 top – Display Linux tasks
 vmstat – Report virtual memory statistics Red Hat-based (e.g., CentOS, Fedora)
Page | 3 Page | 4
 yum – Package manager for RPM-based systems 11. Scheduling Tasks
o yum install <package> – Install a package

o yum update – Update installed packages  cron – Daemon for running scheduled commands
o yum remove <package> – Remove a package o crontab -e – Edit cron jobs for the current user

 dnf – Next-generation package manager (Fedora, CentOS 8+) o crontab -l – List the current user’s cron jobs

o dnf install <package> – Install a package o crontab -r – Remove the current user's cron jobs

o dnf update – Update installed packages  at – Run commands at a specified time


o dnf remove <package> – Remove a package o at 09:00 – Schedule a command to run at 09:00 AM

 batch – Run commands when the system load is low


General Commands  sleep – Delay for a specified time
o sleep 5s – Sleep for 5 seconds
 rpm – RPM package manager
o rpm -i <package.rpm> – Install an RPM package

o rpm -e <package> – Remove an RPM package


12. File Permissions and Security
 dpkg – Debian package manager  chmod – Change file permissions
o dpkg -i <package.deb> – Install a Debian package
 chown – Change file owner and group
o dpkg -r <package> – Remove a Debian package
 chgrp – Change the group ownership of a file
 umask – Set default permissions for new files
10. System Services and Daemon Management  setfacl – Set file access control lists (ACL)
 systemctl – Control the systemd system and service manager  getfacl – Get file access control lists (ACL)
o systemctl start <service> – Start a service
 sudo – Execute a command as another user (usually root)
o systemctl stop <service> – Stop a service
 visudo – Edit the sudoers file safely
o systemctl restart <service> – Restart a service
 passwd – Change a user’s password
o systemctl enable <service> – Enable a service to start on boot
 sudoers – Manage sudo access for users
o systemctl disable <service> – Disable a service from starting
 gpasswd – Administer group password
on boot  ss – Display socket statistics (for secure network connections)
o systemctl status <service> – Check service status

 service – Older service management command (used in non-


13. System Backup and Restore
systemd systems)  rsync – Remote file and directory synchronization
o service <service> start – Start a service
o rsync -avz source/ destination/ – Synchronize files
o service <service> stop – Stop a service
o rsync -avz -e ssh source/ user@remote:/destination/ – Sync
o service <service> restart – Restart a service
over SSH
o service <service> status – Check service status
 cpio – Copy files to and from archives
 dd – Low-level copying and backup of entire filesystems
Page | 5 Page | 6
o dd if=/dev/sda of=/path/to/backup.img – Backup a o ip route – Show or manipulate routing tables
disk/partition  ss – Display socket statistics (useful for diagnosing network
o dd if=/path/to/backup.img of=/dev/sda – Restore a issues)
disk/partition  nmap – Network exploration tool (can be used for security
auditing)
14. System Diagnostics and Troubleshooting  telnet – User interface to the TELNET protocol (less common
nowadays)
 dmesg – Print the kernel ring buffer messages (system boot and  nc (Netcat) – Network utility for reading and writing from network
hardware-related messages) connections
 journalctl – Query and view logs from systemd’s journal o nc -l -p 1234 – Listen on port 1234
 strace – Trace system calls and signals o nc <host> <port> – Connect to a host and port
o strace <command> – Trace a command’s system calls
 iptables – Administration tool for IPv4 packet filtering and NAT
 lsof – List open files (useful for debugging) (Network Address Translation)
o lsof <file> – Show processes using a specific file
 firewalld – Frontend for managing firewall rules (used in some
 vmstat – Report virtual memory statistics distros like Fedora and CentOS)
 iostat – Report CPU and I/O statistics  ufw – Uncomplicated firewall (front-end for iptables)
 mpstat – Report CPU usage statistics o ufw enable – Enable firewall
 pidstat – Report statistics by process o ufw allow <port> – Allow traffic on a specific port
 free – Display memory usage  tcpdump – Command-line packet analyzer
 uptime – How long the system has been running  curl – Transfer data from or to a server using various protocols
 watch – Execute a program periodically, showing output (HTTP, FTP, etc.)
o watch -n 1 free – Watch memory usage every second
 wget – Download files from the web via HTTP, HTTPS, FTP
 lshw – List hardware configuration  scp – Secure copy over SSH (used to copy files between systems)
 htop – Interactive process viewer (better than top) o scp file.txt user@remote:/path/to/destination/ – Copy file to
 netstat – Network statistics (deprecated in favor of ss) remote server
 ss – Show socket statistics (more efficient than netstat)  rsync – Remote file and directory synchronization (often used for
backups)
15. Networking & Remote Management o rsync -avz /local/path/ remote:/remote/path/ – Sync

 ifconfig – Configure network interfaces (older command, directories


replaced by ip)
 ip – A more modern alternative for managing network interfaces 16. Text Processing Utilities
and routing  grep – Search for patterns within files
o ip addr – Show IP addresses
o grep 'pattern' file.txt – Search for a pattern in a file
o ip link – Show or manipulate network interfaces
o grep -r 'pattern' /dir/ – Recursively search for a pattern
Page | 7 Page | 8
 sed – Stream editor for filtering and transforming text  init – Change the runlevel (old-style system manager)
o sed 's/old/new/g' file.txt – Replace old with new globally o init 0 – Shutdown

 awk – A powerful text processing language o init 6 – Reboot

o awk '{print $1}' file.txt – Print the first column of each line in

a file 18. File System Mounting and Management


 cut – Remove sections from each line of a file
o cut -d ':' -f 1 /etc/passwd – Print the first field of each line,
 mount – Mount a file system
o mount /dev/sda1 /mnt – Mount partition to a directory
delimited by ":"
 sort – Sort lines of text files  umount – Unmount a file system
o umount /mnt – Unmount the file system mounted at /mnt
o sort file.txt – Sort file content in ascending order

 uniq – Report or omit repeated lines in a file  fstab – File system table (configuration file for mounting file
o sort file.txt | uniq – Sort and remove duplicate lines
systems)
o /etc/fstab – View and configure persistent mount points
 tee – Read from standard input and write to standard output and
files  blkid – Display block device attributes
o echo "text" | tee file.txt – Write to file and show output on
 fsck – Check and repair a file system
o fsck /dev/sda1 – Check and repair /dev/sda1
screen
 tr – Translate or delete characters
o echo "hello" | tr 'a-z' 'A-Z' – Convert lowercase to uppercase
19. Filesystem Permissions and Security
 paste – Merge lines of files  chmod – Change file permissions
o paste file1.txt file2.txt – Combine lines of file1 and file2 side o chmod 755 file.txt – Give read, write, and execute
by side permissions to owner, and read-execute permissions to
 wc – Word, line, character, and byte count others
o wc -l file.txt – Count lines in a file  chown – Change file owner and group
o wc -w file.txt – Count words in a file o chown user:group file.txt – Change owner and group of a file

 chgrp – Change group ownership of a file


17. System Shutdown and Reboot o chgrp group file.txt – Change the group of a file

 shutdown – Shut down the system  umask – Set default permissions for new files
o umask 022 – Set default permissions for newly created files
o shutdown -h now – Immediately shut down

o shutdown -r now – Reboot the system


to 755
o shutdown -h +10 – Shut down after 10 minutes
 setfacl – Set access control lists (ACL) for file permissions
 reboot – Reboot the system  getfacl – Get access control lists (ACL) for file permissions
 halt – Halt the system immediately (equivalent to turning off
power)
 poweroff – Power off the system
Page | 9 Page | 10
20. Containerization and Orchestration o kubectl apply -f <file>.yaml – Apply configuration
from a file (e.g., a deployment or pod configuration)
Docker o kubectl create -f <file>.yaml – Create a resource
from a file
 docker – Docker command-line interface (CLI) for managing o kubectl delete -f <file>.yaml – Delete a resource
containers defined in a file
o docker run <image> – Run a container from an image
o kubectl exec -it <pod_name> -- bash – Execute a
o docker ps – List running containers
command inside a pod (e.g., open a shell)
o docker ps -a – List all containers, including stopped ones
o kubectl logs <pod_name> – View the logs of a pod
o docker build -t <image_name> . – Build an image
o kubectl describe pod <pod_name> – Get detailed
from a Dockerfile information about a pod
o docker exec -it <container_id> bash – Start an
o kubectl scale deployment <deployment_name> --
interactive bash shell inside a running container replicas=<number> – Scale a deployment to the desired
o docker stop <container_id> – Stop a container
number of replicas
o docker rm <container_id> – Remove a container
o kubectl rollout restart deployment
o docker logs <container_id> – View logs of a container
<deployment_name> – Restart a deployment
o docker images – List available images
o kubectl port-forward pod <pod_name>
o docker rmi <image_name> – Remove an image
<local_port>:<remote_port> – Forward a port from a
o docker network ls – List Docker networks
pod to localhost
o docker-compose – Manage multi-container Docker

applications Helm
 docker-compose up – Start up a multi-container
 helm – Kubernetes package manager for deploying applications
environment
o helm install <release_name> <chart_name> –
 docker-compose down – Stop and remove containers
Install a Helm chart
created by docker-compose
o helm upgrade <release_name> <chart_name> –
 docker-compose logs – View logs from containers
Upgrade a Helm release
managed by docker-compose
o helm list – List all Helm releases

Kubernetes (k8s) o helm delete <release_name> – Delete a Helm release

o helm search <chart_name> – Search for a Helm chart


 kubectl – Command-line tool for interacting with Kubernetes
clusters 21. Automation and Configuration Management
o kubectl get pods – List pods in the current namespace

o kubectl get nodes – List nodes in the cluster Ansible


o kubectl get services – List services in the cluster
 ansible – Automation tool for configuration management
Page | 11 Page | 12
o ansible all -m ping – Ping all hosts defined in the o puppet resource – Show the current state of resources
inventory (files, services, etc.)
o ansible-playbook playbook.yml – Run an Ansible
playbook 22. CI/CD Tools and Commands
o ansible -m command -a 'command' <host> – Run a
single command on a target host Jenkins
o ansible-playbook --check playbook.yml – Dry-run  jenkins – Continuous integration tool
a playbook to see what would change o java -jar jenkins.war – Start Jenkins from a WAR file
o ansible-playbook --limit <host> playbook.yml – o Access Jenkins through http://localhost:8080 by default
Run a playbook on a specific host or group
o ansible-playbook --extra-vars "key=value" – GitLab CI
Pass extra variables to a playbook
 .gitlab-ci.yml – Configuration file for GitLab CI/CD pipelines
Terraform (typically resides in your repository)
o gitlab-runner register – Register a new runner with
 terraform – Infrastructure as code tool for provisioning and GitLab
managing cloud resources o gitlab-runner run – Run the GitLab Runner to process
o terraform init – Initialize a working directory for
jobs
Terraform configuration
o terraform plan – Show an execution plan (preview of GitHub Actions
what changes will be made)
 GitHub Actions uses YAML configuration files (typically located in
o terraform apply – Apply the changes described in a
.github/workflows/)
Terraform configuration
o actions/checkout@v2 – Checkout the repository code in
o terraform destroy – Destroy infrastructure created by
your CI pipeline
Terraform
o actions/setup-node@v2 – Setup Node.js for use in a
o terraform validate – Validate the configuration files
pipeline
o terraform show – Show the current state of the
o docker/setup-buildx-action@v1 – Set up Docker
infrastructure
Buildx for building multi-platform images
Puppet
23. Cloud Services
 puppet – Configuration management tool
o puppet apply <manifest.pp> – Apply a Puppet AWS CLI (Amazon Web Services)
manifest locally
 aws – Command-line tool for managing AWS services
o puppet agent --test – Test the Puppet agent (can be
o aws configure – Configure AWS CLI with your credentials
used to run a one-off run)
Page | 13 Page | 14
o aws s3 cp file.txt s3://bucket-name/ – Copy a  prometheus – Open-source system monitoring and alerting
file to an S3 bucket toolkit
o aws ec2 describe-instances – Describe EC2 instances o prometheus – Start Prometheus server (usually runs as a

o aws ec2 start-instances --instance-ids <id> – service in the background)


Start an EC2 instance o prometheus --config.file=<config_file> – Start

o aws ec2 stop-instances --instance-ids <id> – Prometheus with a specific config file
Stop an EC2 instance
o aws s3 sync – Sync directories with an S3 bucket Grafana

Azure CLI (Microsoft Azure)  grafana-cli – Command-line interface for managing Grafana
plugins
 az – Command-line tool for managing Azure services o grafana-cli plugins install <plugin-name> –

o az login – Log in to your Azure account Install a plugin in Grafana


o az vm list – List all virtual machines

o az vm start --name <vm_name> --resource-group


ELK Stack (Elasticsearch, Logstash, Kibana)
<resource_group> – Start an Azure VM  elasticsearch – Search engine for logging and data analytics
o az storage blob upload – Upload files to an Azure
o curl -XGET
blob storage 'localhost:9200/_cluster/health?pretty' – Get
o az group create – Create a new resource group in Azure
cluster health status
Google Cloud SDK (gcloud)  logstash – Server-side data processing pipeline
o logstash -f <config_file> – Run Logstash with the

 gcloud – Command-line tool for Google Cloud Platform specified configuration file
o gcloud auth login – Log in to Google Cloud  kibana – Web interface for visualizing Elasticsearch data
o gcloud compute instances list – List compute o Kibana is generally accessed through a web browser

instances (http://localhost:5601)
o gcloud compute instances stop <instance_name>

– Stop a Google Cloud VM instance


o gcloud app browse – Open the current Google App

Engine application in a browser

24. Logging and Monitoring


Prometheus

Page | 15 Page | 16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy