Master Essential Linux Commands: Login, Shutdown, File Management & More
This guide introduces the most frequently used Linux commands—including login, shutdown, halt, reboot, install, mount, umount, chsh, exit, last, file, mkdir, grep, dd, find, mv, ls, diff, cmp, cat, and ln—explaining their purpose, syntax, key options, and practical examples to help users efficiently manage files, processes, and system operations.
Linux provides a wealth of commands that enable efficient disk operations, file access, directory management, process control, and permission settings. Understanding these commands is essential for mastering the Linux system.
Login Commands
login logs a user into the system (available to all users). Syntax: login [name] [-p] [-h hostname]. Options: -p preserves the current environment; -h specifies a remote host. After entering the username and password, the system displays the login prompt and, upon successful authentication, shows the shell prompt (e.g., [root@localhost root]#).
Linux supports multiple virtual consoles (Alt+F1‑F6) allowing simultaneous logins and providing a fallback when a program crashes.
Shutdown and Power‑off Commands
shutdown safely powers off the computer (super‑user only). Syntax: shutdown [-h] [-i] [-k] [-m] [-t]. Important options: -t sets a delay before shutdown; -k sends a warning without actually shutting down; -h powers off after shutdown; -c cancels a pending shutdown; -F forces a filesystem check on reboot; -i displays system information.
Example: shutdown -h 3:40 schedules shutdown at 3:40.
Halt, Reboot and Install
halt stops the system (super‑user only). Syntax: halt [-n] [-w] [-d] [-f] [-i] [-p]. It kills processes, syncs buffers, and either powers off (level 0/6) or invokes shutdown -h otherwise.
reboot restarts the computer (system administrator). Syntax: reboot [-n] [-w] [-d] [-f] [-i]. Options control whether buffers are written, logs are updated, or network interfaces are stopped.
install copies or upgrades files and can create directories. Syntax examples: install [options] source destination, install [options] source... directory, install -d [options] directory.... Options include --backup, -b, -d, -m, -o, -p, -v, etc.
Mounting and Unmounting Filesystems
mount attaches a filesystem to the directory tree. Syntax: mount -a [-fv] [-t fstype] [-n] [-rw] [-F] device dir. Common options: -a mounts all filesystems from /etc/fstab, -t specifies the type (e.g., vfat, ext2, iso9660), -F runs mount in the background, -f performs a dry run, -v enables verbose output.
Typical usage: mount -t vfat /dev/hda1 /mnt/cdrom. Linux can automatically mount many filesystems; Red Hat often requires manual mounting.
umount detaches a mounted filesystem. Syntax: umount -a [-fFnrsvw] [-t fstype] [-n] [-rw] [-F] device dir. It works like the inverse of mount and may require that no users are accessing the device.
User Shell Management
chsh changes a user's login shell (available to all users). Syntax: chsh [-s shell] [-list] [--help] [-v] [username]. Options: -l lists available shells; -v shows the shell version.
Example interaction:
Changing login shell for user
Password:
New shell [/bin/bash]: /bin/tcshSession Control Commands
exit terminates the current shell session (all users). Syntax: exit.
last displays recent login sessions (all users). Syntax:
last [-n] [-f file] [-t tty] [-h node] [-I IP] [-1] [-y] [-D] [-x]. Options filter by number of records, log file, terminal, host, IP, etc.
File Inspection and Management
file determines file type by examining its contents. Syntax: file [options] filename. Options: -v shows version, -z checks compressed files, -L follows links, -f name reads a list of files.
Example: file grap → grap: English text.
mkdir creates directories. Syntax: mkdir [options] dirname. Options: -m mode sets permissions, -p creates parent directories as needed, -v prints created directories.
Example: mkdir -m 777 tsk creates tsk with full permissions.
grep searches files for patterns. Syntax: grep [options] pattern [file...]. Common options: -c count matches, -i ignore case, -n show line numbers, -v invert match, etc. Regular‑expression symbols such as ^, $, ., * are explained.
Example: grep '[0-9]\\{3\}\\.[0-9]\\{3\}' ipfile.
Data Copying and Conversion
dd copies and converts data. Syntax: dd [options]. Important options: bs=bytes, cbs=bytes, conv=keywords, count=blocks, if=file, of=file, seek=blocks, skip=blocks.
Typical use: creating a bootable floppy with dd if=vmlinuz of=/dev/fd0.
File Searching
find locates files in a directory hierarchy. Syntax: find [path] [options] [expression]. Options include -depth, -maxdepth n, -mindepth n, -name pattern, -size n, -user name, etc. Examples: find / -name lilo.conf, find /etc -size +500000c -and -mtime +1.
Moving and Renaming
mv moves or renames files and directories. Syntax: mv [options] source target. Options: -i interactive, -f force.
Examples: mv /usr/cbu/* . and mv cjh.txt wjz.txt.
Listing Directory Contents
ls lists directory entries. Syntax: ls [options] [file]. Frequently used options: -a, -l, -R, -h, -S, -t, -r, -1, -F, -i, -g, -G, -n, -p, -Q, -s, -b, -c, -d, -L, -N, -o, -x.
Colors indicate file types: blue for directories, green for executables, red for archives, etc.
File Comparison
diff compares two files. Syntax: diff [options] file1 file2. Options: -a, -b, -B, -c, -H, -I, -n.
cmp reports whether two files differ. Syntax: cmp [options] file1 file2. Option -l prints differing bytes in octal.
Concatenating Files
cat concatenates and displays file contents. Syntax: cat [options] file1 file2 .... Options: -n number all lines, -b number non‑blank lines, -s squeeze multiple blank lines.
Examples: cat README, cat README INSTALL > File1, cat -b /etc/named.conf.
Link Management
ln creates hard or symbolic links. Syntax: ln [options] source [linkname]. Options: -s symbolic link, -f force, -d allow hard‑linking directories, -b backup existing files.
Example: ln -s /usr/local/httpd/htdocs gg creates a shortcut to the web server document root.
Practical Exercises
Run multiple commands in one line using semicolons, e.g., # last -x; halt. Mount Windows partitions with mount -t vfat /dev/hda1 /mnt/winc or with -o iocharset=cp936 to display Chinese filenames correctly. Use mount /dev/sda1 /usb for USB flash drives. Create symbolic links for quick directory access. Use dd if=/dev/fd0 of=floppy.fd and dd if=root.ram of=/dev/ram0 for low‑level operations. Apply grep and find together for advanced searches.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
