Linux is a powerful and versatile operating system, widely used for servers, development, and personal computing. For beginners, the command-line interface (CLI) can seem daunting, but mastering a few essential commands can greatly enhance your Linux experience. This blog post introduces 20 fundamental commands to get you started.
pwd displays the current directory you are in.
pwd
# Output: /home/user/documents ls lists files and directories in the current directory. Useful options include -l for detailed output, -a to show hidden files, and -h for human-readable sizes.
ls
# Output: file1.txt file2.txt directory1
ls -la cd changes the current directory. Use cd .. to go up one level.
cd documents
cd .. mkdir creates a new directory.
mkdir new_directory rmdir removes an empty directory.
rmdir empty_directory rm deletes files. Use -r to remove directories and their contents recursively, and -f to force removal (without prompting). Use with caution!
rm file.txt
rm -rf directory cp copies files and directories. Use -r to copy directories recursively.
cp file.txt new_file.txt
cp -r directory new_directory mv moves or renames files and directories.
mv file.txt new_location/
mv old_name.txt new_name.txt cat displays the content of a file. It can also concatenate multiple files.
cat file.txt
cat file1.txt file2.txt > combined.txt less displays file content page by page, allowing navigation within the file. Use Space to go forward, b to go back, and q to quit.
less large_file.txt head displays the first lines of a file (default: 10 lines).
head file.txt
head -n 20 file.txt # Display the first 20 lines tail displays the last lines of a file (default: 10 lines). Useful with -f to follow changes in a file (e.g., log files).
tail file.txt
tail -f log_file.log touch creates an empty file or updates the access and modification time of an existing file.
touch new_file.txt find searches for files and directories based on various criteria (name, size, etc.).
find . -name "file.txt" # Find files named "file.txt" in the current directory and subdirectories
find /path/to/search -type d # Find all directories man displays the manual page for a command, providing detailed information and options.
man ls echo displays text or variables to the terminal.
echo "Hello, world!"
echo $HOME # Display the value of the HOME environment variable history displays a list of previously executed commands.
history ps displays information about running processes. Common options include aux for a detailed list of all processes.
ps aux top displays a dynamic real-time view of running processes, including CPU and memory usage.
top kill sends a signal to a process. The most common signal is SIGTERM (15) to request termination. You'll need the process ID (PID), which you can get from ps or top. Use kill -9 (SIGKILL) as a last resort, as it forcefully terminates the process.
kill 1234
kill -9 5678 These 20 commands provide a solid foundation for navigating and interacting with the Linux command-line. Practice using them regularly, and you'll quickly become more comfortable and efficient in your Linux environment. Remember to consult the man pages for more detailed information about each command and its options. Happy Linuxing!
---
This essential commands guide connects to our comprehensive Linux mastery series!
Ready for Structured Learning? Start with our complete Linux series:
Beginner Skills (Start Here!):
This guide covers similar concepts to Parts 2-3 of our structured series. Continue with the organized curriculum for systematic learning!
- Linux Terminal Commands - Detailed command explanations
After mastering these basics, explore:
---
Ready for systematic Linux mastery? Start with our structured series to build comprehensive skills step-by-step!