Skip to main content

linux

Cheat Sheet: UNIX Commands




1. Basic Commands

CommandDescriptionExample
lsList directory contentsls -l (detailed list)
cdChange directorycd /home
pwdPrint working directorypwd
mkdirCreate a new directorymkdir newdir
rmdirRemove an empty directoryrmdir olddir
rmRemove files or directoriesrm file.txt
cpCopy files or directoriescp src dest
mvMove or rename files or directoriesmv old new

2. Networking

CommandDescriptionExample
ifconfigConfigure network interface parametersifconfig eth0
pingCheck network connectivityping google.com
netstatNetworking statisticsnetstat -r
tracerouteTrace route to a network hosttraceroute google.com

3. File Permissions and Ownership

CommandDescriptionExample
chmodChange file modes or Access Control Lists (ACL)chmod 755 file.sh
chownChange file owner and groupchown user:group file
umaskSet default file permissionsumask 022

4. Process Management

CommandDescriptionExample
psReport a snapshot of current processesps aux
topDisplay Linux taskstop
killSend a signal to a processkill -9 1234
nohupRun a command immune to hangupsnohup ./script.sh &

5. System Information and Performance

CommandDescriptionExample
unamePrint system informationuname -a
dfReport file system disk space usagedf -h
duEstimate file space usagedu -sh /home/
freeDisplay memory usagefree -m

6. Archiving and Compression

CommandDescriptionExample
tarStore and extract files from a tarfiletar -xvf file.tar
gzipCompress or expand filesgzip file
gunzipDecompress filesgunzip file.gz

7. Text Processing

CommandDescriptionExample
grepSearch text for patternsgrep "hello" file
awkPattern scanning and processing languageawk '{print $1}' file
sedStream editor for filtering and transformingsed 's/old/new/g' file

8. Scripting and Automation

CommandDescriptionExample
bashExecute commands from a file or stringbash script.sh
crontabSchedule periodic background jobscrontab -e

9. User and Group Management

CommandDescriptionExample
useraddCreate a new user accountuseradd newuser
usermodModify a user accountusermod -aG sudo newuser
userdelDelete a user accountuserdel olduser
groupaddCreate a new groupgroupadd newgroup
groupdelDelete a groupgroupdel oldgroup
passwdChange or set a user passwordpasswd username

10. Advanced File Manipulation

CommandDescriptionExample
findSearch for files in a directory hierarchyfind / -name "myfile.txt"
locateFind files by name using indexed databaselocate myfile.txt
touchChange file timestamps or create empty filestouch newfile.txt
lnCreate hard and symbolic linksln -s sourcefile link

11. System Services and Process Control

CommandDescriptionExample
systemctlControl and manage systemd system and servicessystemctl status nginx
serviceManage SysV servicesservice nginx start
psReport a snapshot of current processesps aux
killSend a signal to a processkill -9 1234
topDisplay and update sorted information about processestop
htopInteractive process viewer (enhanced top)htop

12. Networking and Firewalls

CommandDescriptionExample
ipShow / manipulate routing, devices, policy routingip addr show
iptablesAdministration tool for IPv4 packet filtering and NATiptables -L
firewalldManage firewall with zonesfirewall-cmd --list-all-zones
ssUtility to investigate socketsss -tulwn

13. System Monitoring and Logs

CommandDescriptionExample
dmesgDisplay message or driver message from kernel ring buffer`dmesg
vmstatReport virtual memory statisticsvmstat 1 5
iostatReport CPU statistics and I/O statisticsiostat 1 5
netstatPrint network connections, routing tables, interface statisticsnetstat -r
journalctlQuery contents of systemd journaljournalctl -u nginx.service

14. Archiving and Compression

CommandDescriptionExample
tarArchive filestar -cvf archive.tar /dir
gzipCompress or expand filesgzip file
gunzipDecompress filesgunzip file.gz
zipPackage and compress fileszip archive.zip file1 file2
unzipExtract compressed files in a ZIP archiveunzip archive.zip

15. Text Processing

CommandDescriptionExample
grepSearch text for patternsgrep "pattern" file
awkPattern scanning and processing languageawk '/pattern/ {print $1}' file
sedStream editor for filtering and transforming textsed 's/old/new/g' file
cutRemove sections from each line of files`cut -

Comments

Popular posts from this blog

DevOps Vs DevSecOps

   DevOps and DevSecOps are two methodologies that have gained traction in the IT industry for streamlining software development and deployment. However, their approach to security and operations differs, making each suitable for different types of projects and organizational needs. Let's explore DevOps versus DevSecOps with a real-time example, focusing on their distinctions, integration, and practical applications. DevOps: The Foundation DevOps is a cultural and professional movement that emphasizes collaboration and communication between software developers and other IT professionals while automating the process of software delivery and infrastructure changes. It aims to shorten the development life cycle and provide continuous delivery with high software quality. Core Principles: Continuous Integration and Continuous Deployment (CI/CD): Automate building, testing, and deployment of applications. Collaboration: Breaking down silos between teams (developers, IT operations...

Deploying a Node.js project to Azure App Services using Azure DevOps pipelines

Deploying a Node.js project to Azure App Services using Azure DevOps pipelines is a robust way to automate deployment processes and integrate continuous integration and deployment (CI/CD) practices into your workflow. This guide will walk you through the setup of an Azure DevOps pipeline to deploy a Node.js application from GitHub or Azure Repos to Azure App Services. Prerequisites Before you begin, ensure you have the following: An Azure account. You can sign up for a free account here . A GitHub or Azure Repos account with your Node.js project. An Azure DevOps account. Create one here if you don't have it. Step 1: Prepare Your Node.js Application Make sure your Node.js application is ready and includes a package.json file in the root. This file is crucial as it contains dependency information and scripts needed for your application. Step 2: Create an Azure Web App Log into Azure Portal: Visit https://portal.azure.com . Create a Web App: Click on "Create a resource". ...

Git Cheat Sheet

  Git Cheat Sheet Category Command Description Setup git config --global user.name "[name]" Set a name that will be attached to your commits and tags. git config --global user.email "[email]" Set an email that will be attached to your commits and tags. git init Initialize a new git repository in the current directory. git clone [url] Clone a repository into a new directory. Stage & Snapshot git status Show modified files in the working directory, staged for your next commit. git add [file] Add a file as it looks now to your next commit (stage). git reset [file] Unstage a file while retaining the changes in the working directory. git diff Show diff of what is changed but not staged. git diff --staged Diff of what is staged but not yet committed. git commit -m "[message]" Commit your staged content as a new commit snapshot. Branch & Merge git branch List all of the branches in your repo. git branch [name] Create a new branch at the current commit. gi...