Gratis omvandlare

Linux / Bash Command Cheat Sheet

Omfattande Linux- och Bash-kommandofuskblad. Sök i 80+ viktiga kommandon med exempel, beskrivningar och kopiera med ett klick.

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

Om detta verktyg

En omfattande snabbreferensguide för linux bash. Bläddra bland vanliga kommandon, syntax och exempel ordnade efter kategori. Sökbar och mobilvänlig – bokmärk den här sidan för omedelbar åtkomst när du behöver en snabb påminnelse.

Så här använder du det

  1. Bläddra i de kategoriserade referenssektionerna.
  2. Använd sökfältet för att hitta specifika kommandon eller syntax.
  3. Klicka på valfri post för att se användningsexempel och förklaringar.
  4. Kopiera kommandon direkt för användning i din terminal eller editor.

Vanliga frågor

Är denna referens aktuell?
Referensen täcker ofta använda kommandon och syntax som är stabila över versioner. Se den officiella dokumentationen för de senaste tilläggen eller versionsspecifika funktionerna.
Kan jag använda detta offline?
När den väl har laddats fungerar sidan utan internetanslutning. Bokmärk det för snabb åtkomst – allt innehåll renderas i webbläsaren utan ytterligare nätverksbegäranden.
Är detta heltäckande eller bara grunderna?
Den täcker de vanligaste kommandona och mönstren som hanterar 90 % av vardagliga uppgifter. För nischade eller avancerade funktioner, se den officiella dokumentationen.
Kan jag föreslå tillägg?
Vi uppdaterar regelbundet våra referenser. Om du märker att kommandon saknas eller har förslag, låt oss veta det via vår kontaktsida.