Getting Started with UNIX
UNIX is built around a simple yet powerful design philosophy: “Everything is a file.” This allows UNIX to be highly adaptable across different computing environments.
Basic UNIX Commands
Command | Description |
---|---|
ls | Lists files in a directory |
cd | Changes directory |
mkdir | Creates a new directory |
rm | Deletes a file or directory |
cp | Copies files |
mv | Moves or renames files |
chmod | Changes file permissions |
grep | Searches text within files |
ps | Displays active processes |
kill | Terminates a process |
UNIX File System & Navigation
The UNIX file structure is hierarchical, starting from the root directory /
. Learn how to navigate and manage files efficiently.
Key Directories in UNIX:
/
- Root directory/bin
- Essential user binaries/etc
- System configuration files/home
- User home directories/var
- Variable data (logs, databases)/usr
- User-related programs and libraries
Editing Text Files
UNIX provides several powerful tools to edit text files directly from the terminal. Here are the most commonly used editors:
1. nano
(Beginner-Friendly)
nano
is a straightforward text editor ideal for beginners. It displays commands at the bottom of the screen and is easy to use.
Example: nano myfile.txt
Use Ctrl + O
to save and Ctrl + X
to exit.
2. vi
or vim
(Advanced)
vi
is a powerful editor built into most UNIX systems. vim
is an improved version with extended features. These editors have two modes: normal mode and insert mode.
Example: vi myfile.txt
i
– Enter insert modeEsc
– Return to command mode:w
– Save changes:q
– Quit:wq
– Save and quit
3. cat
and echo
(Quick Edits)
For very small edits, cat
and echo
can be used to create or append to files directly.
Create a file: echo "Hello, UNIX!" > hello.txt
Append to a file: echo "Another line" >> hello.txt
View a file: cat hello.txt
Each tool has its strengths — start with nano
and gradually explore vim
as you become more comfortable with UNIX.