Bezmaksas pārveidotājs

Linux / Bash Command Cheat Sheet

Visaptveroša Linux un Bash komandu apkrāpšanas lapa. Meklējiet vairāk nekā 80 būtisku komandu ar piemēriem, aprakstiem un kopiju ar vienu klikšķi.

ls
List directory contents
Piemērs:ls -la /home/user
ls -la
List all files including hidden, with details
Piemērs:ls -la ~/Documents
cd
Change directory
Piemērs:cd /var/log
pwd
Print working directory path
Piemērs:pwd
mkdir
Create a new directory
Piemērs:mkdir -p /tmp/mydir/subdir
rm
Remove files or directories
Piemērs:rm -rf /tmp/oldfiles
cp
Copy files or directories
Piemērs:cp -r /src/dir /dst/dir
mv
Move or rename files/directories
Piemērs:mv oldname.txt newname.txt
touch
Create an empty file or update timestamp
Piemērs:touch newfile.txt
find
Search for files in a directory hierarchy
Piemērs:find /home -name '*.log' -mtime -7
locate
Find files by name using a prebuilt database
Piemērs:locate nginx.conf
ln
Create hard or symbolic links
Piemērs:ln -s /path/to/target /path/to/link
df
Report disk space usage of file systems
Piemērs:df -h
du
Estimate file space usage
Piemērs:du -sh /var/log/*
stat
Display file or file system status
Piemērs:stat /etc/passwd
file
Determine file type
Piemērs:file /usr/bin/bash
cat
Concatenate and display file contents
Piemērs:cat /etc/hosts
less
View file content one screen at a time
Piemērs:less /var/log/syslog
more
View file content page by page
Piemērs:more /etc/passwd
head
Output the first part of a file
Piemērs:head -n 20 /var/log/auth.log
tail
Output the last part of a file
Piemērs:tail -f /var/log/syslog
grep
Search text using patterns
Piemērs:grep -rn 'error' /var/log/
sed
Stream editor for filtering and transforming text
Piemērs:sed 's/old/new/g' file.txt
awk
Pattern scanning and text processing language
Piemērs:awk '{print $1, $3}' access.log
sort
Sort lines of text files
Piemērs:sort -k2 -n data.txt
uniq
Report or omit repeated lines
Piemērs:sort file.txt | uniq -c
wc
Print newline, word, and byte counts
Piemērs:wc -l /etc/passwd
cut
Remove sections from each line of files
Piemērs:cut -d: -f1 /etc/passwd
tr
Translate or delete characters
Piemērs:echo 'hello' | tr 'a-z' 'A-Z'
echo
Display a line of text
Piemērs:echo "Hello, World!"
printf
Format and print data
Piemērs:printf "%s\t%d\n" name 42
diff
Compare files line by line
Piemērs:diff file1.txt file2.txt
tee
Read from stdin and write to stdout and files
Piemērs:ls | tee output.txt
ps
Report a snapshot of current processes
Piemērs:ps aux | grep nginx
top
Display Linux processes in real time
Piemērs:top -u www-data
htop
Interactive process viewer (ncurses-based)
Piemērs:htop
kill
Send a signal to a process
Piemērs:kill -9 1234
killall
Kill processes by name
Piemērs:killall firefox
bg
Resume a suspended job in the background
Piemērs:bg %1
fg
Bring a job to the foreground
Piemērs:fg %1
jobs
List active jobs in the current shell
Piemērs:jobs -l
nohup
Run a command immune to hangups
Piemērs:nohup ./script.sh &
nice
Run a command with modified scheduling priority
Piemērs:nice -n 10 ./heavy_task.sh
systemctl
Control the systemd system and service manager
Piemērs:systemctl restart nginx
service
Run a System V init script
Piemērs:service apache2 status
ping
Send ICMP ECHO_REQUEST to network hosts
Piemērs:ping -c 4 google.com
curl
Transfer data from or to a server
Piemērs:curl -L -o file.zip https://example.com/file.zip
wget
Non-interactive network downloader
Piemērs:wget -q https://example.com/file.tar.gz
ssh
OpenSSH remote login client
Piemērs:ssh -i ~/.ssh/key.pem user@host
scp
Secure copy files between hosts
Piemērs:scp user@host:/path/file.txt ./local/
rsync
Remote file copying tool with delta transfer
Piemērs:rsync -avz /src/ user@host:/dst/
netstat
Print network connections and routing tables
Piemērs:netstat -tulpn
ss
Utility to investigate sockets
Piemērs:ss -tulwn
ifconfig
Configure a network interface
Piemērs:ifconfig eth0
ip
Show and manipulate routing, devices, and tunnels
Piemērs:ip addr show
nmap
Network exploration tool and port scanner
Piemērs:nmap -sV 192.168.1.0/24
dig
DNS lookup utility
Piemērs:dig +short A google.com
nslookup
Query Internet name servers interactively
Piemērs:nslookup example.com
chmod
Change file mode bits (permissions)
Piemērs:chmod 755 script.sh
chown
Change file owner and group
Piemērs:chown -R www-data:www-data /var/www
chgrp
Change group ownership
Piemērs:chgrp developers project/
sudo
Execute a command as another user (superuser)
Piemērs:sudo systemctl restart nginx
su
Change user ID or become superuser
Piemērs:su - postgres
passwd
Change user password
Piemērs:passwd username
umask
Set or display the file mode creation mask
Piemērs:umask 022
id
Print user and group information
Piemērs:id username
whoami
Print the current effective user name
Piemērs:whoami
groups
Print the groups a user is in
Piemērs:groups username
tar
Archive files using tape archive format
Piemērs:tar -czvf archive.tar.gz /path/to/dir
tar -x
Extract files from a tar archive
Piemērs:tar -xzvf archive.tar.gz -C /target/
gzip
Compress files using GNU zip
Piemērs:gzip -9 large_file.log
gunzip
Decompress gzip compressed files
Piemērs:gunzip archive.tar.gz
zip
Package and compress files into a ZIP archive
Piemērs:zip -r output.zip /path/to/dir
unzip
Extract files from a ZIP archive
Piemērs:unzip archive.zip -d /target/
bzip2
Compress files using bzip2 algorithm
Piemērs:bzip2 -z large_file.txt
xz
Compress files using the XZ algorithm
Piemērs:xz -z -9 file.txt
uname
Print system information
Piemērs:uname -a
uptime
Tell how long the system has been running
Piemērs:uptime
free
Display amount of free and used memory
Piemērs:free -h
lscpu
Display information about the CPU architecture
Piemērs:lscpu
lsblk
List information about block devices
Piemērs:lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
lspci
List all PCI devices
Piemērs:lspci -v | grep VGA
dmesg
Print or control the kernel ring buffer
Piemērs:dmesg | tail -50
journalctl
Query and display messages from the journal
Piemērs:journalctl -u nginx --since '1 hour ago'
history
Display the command history list
Piemērs:history | grep docker
env
Print environment variables
Piemērs:env | grep PATH
if / then / fi
Conditional execution in shell scripts
Piemērs:if [ -f file.txt ]; then echo exists; fi
for
Loop over a list of items
Piemērs:for i in 1 2 3; do echo $i; done
while
Execute commands while a condition is true
Piemērs:while read line; do echo $line; done < file
case
Multi-branch conditional matching pattern
Piemērs:case "$var" in a) echo A;; b) echo B;; esac
function
Define a shell function
Piemērs:greet() { echo "Hello, $1!"; }; greet World
export
Set environment variables for child processes
Piemērs:export MY_VAR=value
source
Execute commands from a file in current shell
Piemērs:source ~/.bashrc
alias
Create an alias for a command
Piemērs:alias ll='ls -la'
cron / crontab
Schedule commands to run periodically
Piemērs:crontab -e # 0 * * * * /path/to/script.sh
at
Execute commands at a specified time
Piemērs:echo 'ls /tmp' | at 14:30

Par šo rīku

Visaptveroša ātrās uzziņas rokasgrāmata par Linux bash. Pārlūkojiet biežāk lietotās komandas, sintaksi un piemērus, kas sakārtoti pēc kategorijas. Meklējama un mobilajām ierīcēm draudzīga — atzīmējiet šo lapu ar grāmatzīmi, lai nekavējoties piekļūtu, kad nepieciešams ātrs atgādinājums.

Kā lietot

  1. Pārlūkojiet kategorizētās atsauces sadaļas.
  2. Izmantojiet meklēšanas joslu, lai atrastu noteiktas komandas vai sintaksi.
  3. Noklikšķiniet uz jebkura ieraksta, lai skatītu lietošanas piemērus un skaidrojumus.
  4. Kopējiet komandas tieši izmantošanai terminālī vai redaktorā.

Bieži uzdotie jautājumi

Vai šī atsauce ir atjaunināta?
Atsauce aptver plaši izmantotās komandas un sintaksi, kas ir stabilas dažādās versijās. Lai iegūtu jaunākos papildinājumus vai versijai specifiskus līdzekļus, skatiet oficiālo dokumentāciju.
Vai es varu to izmantot bezsaistē?
Pēc ielādes lapa darbojas bez interneta savienojuma. Atzīmējiet to ar grāmatzīmi ātrai piekļuvei — viss saturs tiek atveidots pārlūkprogrammā bez turpmākiem tīkla pieprasījumiem.
Vai tas ir visaptverošs vai tikai pamats?
Tas aptver visbiežāk izmantotās komandas un modeļus, kas apstrādā 90% ikdienas uzdevumu. Lai uzzinātu par nišas vai papildu funkcijām, skatiet oficiālo dokumentāciju.
Vai varu ieteikt papildinājumus?
Mēs regulāri atjauninām savas atsauces. Ja pamanāt, ka trūkst komandu vai jums ir ieteikumi, informējiet mūs, izmantojot mūsu kontaktu lapu.