Essential Linux Commands: ls, pwd, cd, grep, cat, more, echo, hostname, touch, df, vim
This article provides a comprehensive guide to fundamental Linux command‑line tools—including ls, pwd, cd, grep, cat, more, echo, hostname, touch, df, and vim—explaining their purpose, common options, and practical usage examples with sample outputs for system administrators and developers.
Linux developers need to master basic shell commands beyond Python programming; this guide lists eleven essential commands with descriptions, typical options, and example outputs.
1. ls command lists directory contents. Common options include ls -l (long format), ls -a (show hidden files), ls -s (display size in blocks), ls -lh (human‑readable sizes), ls -lrt (sort by modification time), and ls -lrth (human‑readable with time sort). Example:
[oracle@ol6-single single]$ ls -l -rw-r-----. 1 oracle oinstall 5.1G Apr 10 10:50 sysaux02.dbf -rw-r-----. 1 oracle oinstall 8.5G Apr 10 08:05 users01.dbf2. pwd command prints the current working directory. Use pwd for the absolute path and pwd -P to show the physical path of symbolic links.
[oracle@ol6-single oradata]$ pwd /u01/oradata3. cd command changes the current directory. Variants include cd (home), cd - (previous directory), cd .. (parent), and cd /u01 (absolute path).
[oracle@ol6-single ~]$ cd /u01/oradata/single [oracle@ol6-single single]$ pwd /u01/oradata/single4. grep command searches text using regular expressions. Syntax: grep [OPTIONS] PATTERN [FILE...]. Frequently used options: -a, -c, -i, -n, -v, -s, --color. Example to find lines containing "passwd": [oracle@ol6-single admin]$ grep -n passwd * 5. cat command concatenates and displays file contents. Options include -b to number non‑blank lines. [oracle@ol6-single admin]$ cat -b file.txt | more 6. more command paginates output, allowing navigation with space, b, and search. [oracle@ol6-single admin]$ more test.txt 7. echo command prints strings or variable values to the terminal.
[oracle@ol6-single admin]$ echo "please wait 2 minute" please wait 2 minute8. hostname command shows or sets the system hostname. Use hostname to display, hostname -i for IP, and hostname newname for a temporary change.
[oracle@ol6-single admin]$ hostname ol6-single9. touch command creates empty files or updates timestamps. Variants: touch file, touch -r source target, touch -t yyyymmddhhmm.ss file.
[oracle@ol6-single admin]$ touch test.txt [oracle@ol6-single admin]$ ls -l test.txt -rw-r--r--. 1 oracle oinstall 31 Apr 11 05:20 test.txt10. df command reports filesystem disk space usage. Use df -a for all filesystems and df -h for human‑readable sizes.
[oracle@ol6-single admin]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 9.9G 3.3G 6.1G 35% / /dev/sdb1 50G 15G 32G 33% /u0111. vim/vi editor provides a powerful text editor for creating and modifying files, similar to Notepad on Windows.
These commands form the core toolkit for daily Linux system navigation, file manipulation, and basic administration.
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.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
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.
