Essential Linux Commands: System Administration and Operations
Expand Support of Mandates
man command
displays a manual on the mandate, its mode of use, and its variants.
System On and Off
shutdown -h 5
: Shut down the system in 5 minutes without restarting.shutdown -h now
: Shut down the system immediately without rebooting.halt
: Shut down the system (same as previous commands).shutdown -r 5
: Shut down the system in 5 minutes and restart.shutdown -r now
: Shut down the system immediately and restart.reboot
: Reboot the system.startx
: Start the graphical environment.
User Administration
adduser LPT
: Add a user named LPT.passwd LPT
: Assign a password to the user LPT.userdel LPT
: Delete the user account LPT.su -
: Gain temporary root privileges (if you know the password).su - LPT
: Gain temporary privileges of user LPT.exit
: Exit the current user profile.
Mounted File System
mount -t iso9660 /dev/cdrom /mnt/cdrom
: Mount the CD-ROM in the specified directory (/mnt/cdrom).mount -t msdos /dev/hda1 /mnt/win_c
: Mount the “C” drive with an MSDOS partition in the specified directory.mount -t vfat /dev/hda1 /mnt/win_c
: Mount the “C” drive with a FAT partition in the specified directory.umount /mnt/cdrom
: Unmount the CD-ROM.umount /mnt/win_c
: Unmount the “C” drive.usermount
: An easy and quick way to mount and unmount drives.
File Treatment
Moving Through Directories
cd /home/LPT
: Enter the directory /home/LPT.cd ..
: Go back to the parent directory.
Listing Files
ls -l
: List files in the current directory with all their attributes.ls -F
: List files in the current directory indicating their type (file, directory, etc.).ls -lc
: List files in columns in the current directory.ls -a
: List all files in the current directory, including hidden files (those that start with “.”).
Deleting Files
rm lpt.txt
: Remove a file named lpt.txt.rm -R /LPT
: Remove a directory named LPT and all its contents recursively.rm -Rf /LPT
: Remove a directory recursively without asking for confirmation (use with caution as root).
Copying and Moving Files
cp lpt.txt /home/LPT
: Copy the file lpt.txt into /home/LPT.mv lpt.txt /home/LPT
: Move the file lpt.txt into /home/LPT.
Renaming Files
mv lpt.txt linux_para_todos.txt
: Rename the file lpt.txt to linux_para_todos.txt.
Wildcards
*
: Represents all. Example: ls *.rpm
(list all files with the .rpm extension).?
: Represents a single character. Example: ls ?.txt
(list all files with a single-character name and the .txt extension).
Compressing and Decompressing Files
tar -zxvf lpt.tar.gz
: Unzip and unpack the file lpt.tar.gz.tar -zcvf lpt.tar.gz /home/LPT
: Create a tar.gz archive named lpt.tar.gz containing the directory /home/LPT.tar -jxvf lpt.tar.bz2
: Unzip and unpack the file lpt.tar.bz2.tar -jcvf lpt.tar.bz2 /home/LPT
: Create a tar.bz2 archive named lpt.tar.bz2 containing the directory /home/LPT.tar -cmf /dev/fd0
: Pack the current directory onto multiple diskettes.
Killing Processes
ps aux
: List the processes currently running.kill -9 123
: Force kill the process with PID number 123.killall mozilla
: Force kill all processes named mozilla.kill -15 123
: Request the process with PID 123 to terminate gracefully (15 is the default signal).kill -l
: List the possible signals that can be sent to processes.top
: Serves as ps
and kill
in a console simultaneously.
Keyboard Shortcuts
[Ctrl] + [Alt] + [Del] Shutdown. Shut down the system in an organized way from a text terminal.
[Ctrl] + [Alt] + [F1]Change the first text terminal.
[Ctrl] + [Alt] + [Fn] Changes to the text terminal number n (n = 1 ,…, 8)
[Ctrl] + [Alt] + [F7] Change to the first terminal X (if you are using one)
[Ctrl] + [Alt] + [Fn] switch to the terminal X number n (n = 7 ,…, 12)
[Tab] Auto-complete the name of a command, file, directory, program, when working on a text terminal.
[ArrowUp] (Arrow) will edit the command history we have written previously in text terminal.
[Shift] [PgUp] Scroll terminal output up in text terminal.
[Shift] [PgDown]: Scroll terminal output down in text terminal.
[Ctrl] + C terminates the current process. If not running background
[Ctrl] + d Terminates the current terminal.
[Ctrl] + s to transfer to the terminal.
[Ctrl] + z Send the current process running in the background.
System S
hostname returns the name of the machine.
uptime Returns the amount of time since the last time the system boots.
uname-a info about the operating system of the machine.
dmesg | more Print Ring buffer in the kernel.
free-tm Information on the amount of memory available and used
df-h Information on all devices mounted on the machine
du-bh / | more info on the space occupied by each subdirectory starting at the root (/)
cat / proc / cpuinfo microprocessor Info
cat / proc / interrupts Information interruptions in use (IRQs)
cat / proc / filesystems information on file systems that can be used (compiled into the kernel).
Information on users who use the system.
LPT id information UID, GID and user GROUPS LPT
Information about the latest last users who have used the system.
/ sbin / ifconfig information on the various network devices
Valuable information on the netstat network connection
Boo searches performed.
find /-name lpt.txt-print ltp.txt file for starting the / and displays it on screen.
find /-name lpt.txt> bú squeda.txt. Ltp.txt file for starting the / and save the output to the file búsqueda.txt
whereis file for the binary files, source and manual pages for a package