Chuleta de comandos de Linux
NUEVOChuleta de comandos de Linux para la terminal: archivos, grep, find, permisos, procesos, disco, red, tar, usuarios y apt o dnf. Con buscador y copia con un clic. Los comandos están en inglés.
Funciona al 100 % en tu navegador — lo que introduces nunca se sube ni se guarda en nuestros servidores.
105 entradas en 12 secciones
Navigation
pwdPrint the current directory.
ls -lahList files with details, hidden files and human-readable sizes.
cd <dir>Change directory.
cd ~Go to your home directory.
cd -Go back to the previous directory.
cd ..Go up one directory.
Files & folders
touch <file>Create an empty file or update its modified time.
mkdir -p a/b/cCreate a folder and any missing parent folders.
cp <src> <dest>Copy a file.
cp -r <dir> <dest>Copy a folder with its contents.
mv <src> <dest>Move or rename a file or folder.
rm <file>Delete a file.
rm -r <dir>Delete a folder and everything in it. There is no trash, so double-check the path.
ln -s <target> <link>Create a symbolic link.
file <name>Show what type of file something is.
View & search
cat <file>Print a file.
less <file>Page through a file (q to quit, / to search).
head -n 20 <file>Show the first 20 lines.
tail -n 20 <file>Show the last 20 lines.
tail -f <file>Follow a file as new lines are added, handy for logs.
wc -l <file>Count lines in a file.
grep "text" <file>Print lines that contain text.
grep -rn "text" .Search recursively and show line numbers.
grep -i "text" <file>Search ignoring case.
find . -name "*.log"Find files by name under the current folder.
find . -type f -mtime -1Find files modified in the last 24 hours.
awk '{print $1}' <file>Print the first column of each line.
sed 's/old/new/g' <file>Replace text and print the result (the file is not changed).
sed -i 's/old/new/g' <file>Replace text in the file itself (GNU sed).
sort <file> | uniq -cCount how often each distinct line appears.
Permissions
Numbers: r=4, w=2, x=1, added per owner, group, others.
chmod 644 <file>Owner can read and write, everyone else can only read.
chmod 755 <file>Owner can read, write and run; others can read and run.
chmod +x <file>Make a file executable.
chmod u+rw,go-w <file>Symbolic form: add read/write for owner, remove write for group and others.
chown user:group <file>Change the owner and group of a file.
chown -R user:group <dir>Change owner and group recursively.
ls -lShow permissions as strings like -rwxr-xr-x.
Processes
ps auxList all running processes.
ps aux | grep <name>Find a process by name.
topLive view of processes and resource use.
htopFriendlier live process viewer (often needs to be installed).
kill <pid>Ask a process to stop (sends SIGTERM).
kill -9 <pid>Force a process to stop (SIGKILL). Use only if a normal kill fails.
pkill <name>Stop processes by name.
command &Run a command in the background.
jobsList background jobs of the current shell.
nohup <command> &Keep a command running after you close the terminal.
Disk
df -hShow free and used space for each mounted disk.
du -sh <dir>Show the total size of a folder.
du -sh * | sort -hSize of each item here, sorted from smallest to largest.
lsblkList disks and partitions.
mountShow mounted file systems.
free -hShow used and free memory.
Network
ping -c 4 <host>Send 4 echo requests to check a host is reachable.
curl -I <url>Fetch only the response headers of a URL.
curl -O <url>Download a file and keep its name.
wget <url>Download a file.
ip addrShow network interfaces and IP addresses.
ss -tulpnList listening TCP and UDP ports with the owning process (may need sudo).
dig <domain>Look up DNS records for a domain.
traceroute <host>Show the route packets take to a host.
ssh user@hostOpen a secure shell on a remote machine.
scp <file> user@host:/pathCopy a file to a remote machine over SSH.
Archive & compress
tar -czf archive.tar.gz <dir>Create a gzip-compressed tar archive.
tar -xzf archive.tar.gzExtract a .tar.gz archive here.
tar -xzf archive.tar.gz -C <dir>Extract into a specific folder.
tar -tf archive.tar.gzList the contents of an archive without extracting.
zip -r archive.zip <dir>Create a zip file from a folder.
unzip archive.zipExtract a zip file.
gzip <file>Compress a file to file.gz (the original is replaced).
Users & sudo
whoamiPrint your user name.
idShow your user id and groups.
sudo <command>Run a command as the administrator (root).
su - <user>Switch to another user with their environment.
sudo adduser <name>Create a user (Debian and Ubuntu).
sudo usermod -aG <group> <user>Add a user to a group without removing existing groups.
passwdChange your password.
System info
uname -aShow kernel and system information.
cat /etc/os-releaseShow the Linux distribution name and version.
uptimeShow how long the system has been running and the load.
datePrint the current date and time.
lscpuShow CPU details.
envList environment variables.
historyList commands you ran before.
man <command>Open the manual page of a command.
Package managers
sudo apt updateRefresh the package list (Debian, Ubuntu).
sudo apt upgradeInstall available updates (Debian, Ubuntu).
sudo apt install <package>Install a package with apt.
sudo apt remove <package>Remove a package with apt.
apt search <term>Search packages with apt.
sudo dnf install <package>Install a package with dnf (Fedora, RHEL, Rocky, Alma).
sudo dnf remove <package>Remove a package with dnf.
sudo dnf upgradeUpdate all packages with dnf.
dnf search <term>Search packages with dnf.
Pipes & redirection
cmd1 | cmd2Send the output of cmd1 into cmd2.
cmd > fileWrite output to a file, replacing it.
cmd >> fileAppend output to a file.
cmd < fileRead input from a file.
cmd 2> errors.txtWrite only error messages to a file.
cmd > out.txt 2>&1Write both normal output and errors to one file.
cmd > /dev/null 2>&1Throw away all output.
cmd1 && cmd2Run cmd2 only if cmd1 succeeded.
cmd1 || cmd2Run cmd2 only if cmd1 failed.
cmd | tee fileShow output and save it to a file at the same time.
xargsTurn input lines into arguments, e.g. find . -name "*.tmp" | xargs rm.
Ejemplos rápidos
Entradas típicas y los resultados que produce esta herramienta.
Descripción general
La línea de comandos de Linux es potente, pero las opciones adecuadas son fáciles de olvidar. Esta chuleta de comandos de Linux reúne los comandos de uso diario para navegar, trabajar con archivos, ver y buscar texto con grep, find, awk y sed, permisos, procesos, disco, red, archivos comprimidos, usuarios e información del sistema.
También cubre los gestores de paquetes apt y dnf y los operadores de tuberías y redirección que permiten encadenar comandos. Los comandos que borran datos, como rm -r y kill -9, se describen con claridad para que sepas qué hacen antes de ejecutarlos.
Los comandos, las opciones y sus descripciones breves se muestran en inglés, igual que en la terminal; solo la interfaz y el texto de la página están traducidos. Usa el filtro para acortar la lista, copia un comando y sustituye los marcadores como <file>. Todo se ejecuta en tu navegador y nada de lo que escribes se envía a ningún sitio.
¿Por qué usar esta herramienta?
- Recuerda las opciones adecuadas en segundos
- Cubre archivos, red, disco y procesos
- apt y dnf lado a lado
- Explicaciones sencillas, sin jerga
- Copia cualquier comando con un clic
Funciones
Archivos y navegación
ls, cd, cp, mv, rm, ln y mkdir -p con sus opciones habituales.
Búsqueda y texto
grep, find, awk, sed, sort y uniq para trabajar con la salida de otros comandos.
Permisos
Números de chmod y formas simbólicas, además de chown.
Herramientas de red
curl, wget, ip, ss, dig, ssh y scp.
apt y dnf
Instala, elimina, actualiza y busca paquetes en ambas familias.
Tuberías y redirección
Operadores como |, >, >>, 2>&1, && y tee.
Cómo se usa
Elige una sección
Desplázate hasta Files, Processes, Network o el tema que necesites (los títulos de sección están en inglés).
O filtra
Escribe una palabra como «port» o «tar» en el cuadro «Filtrar esta chuleta».
Lee qué hace
Revisa la descripción de una línea, en inglés, sobre todo en los comandos que borran datos.
Copia y adapta
Pulsa Copiar, pega en tu terminal y sustituye los marcadores como <file>.