Introduction to Unix
- Introduction to Unix:
- Unix is a powerful and versatile operating system known for its command-line interface (CLI) and multitasking capabilities.
- Key features of Unix include file management, process control, networking, and security.
- Terminal and Shell:
- Unix commands are executed in a terminal, which provides a text-based interface.
- The terminal runs a shell, such as Bash (Bourne Again SHell), where you type commands.
- Navigating the File System:
- Use the
lscommand to list files and directories in the current location. - Use
cdto change directories (e.g.,cd /path/to/directory). - Use
pwdto print the current working directory.
- Use the
- File and Directory Operations:
- Create a new directory:
mkdir directory_name. - Create a new empty file:
touch file_name. - Copy files/directories:
cp source destination. - Move files/directories:
mv source destination. - Remove files:
rm file_name. - Remove directories:
rm -r directory_name(be cautious with this command).
- Create a new directory:
- Working with Files:
- View file content:
cat file_nameorless file_name. - Edit files: Use the text editor
viornano(e.g.,nano file_name).
- View file content:
- Redirection and Pipes:
- Redirect output: Use
>to overwrite and>>to append (e.g.,echo "Hello" > output.txt). - Redirect input: Use
<to read from a file (e.g.,cat < input.txt). - Use pipes
|to send the output of one command as input to another (e.g.,ls | grep keyword).
- Redirect output: Use
- File Permissions:
- Use
chmodto change file permissions (e.g.,chmod 755 file_name). - Permissions are represented as three sets of characters: owner, group, and others (e.g.,
rwxr-xr-x).
- Use
- Process Management:
- View running processes:
psortop. - Terminate a process:
kill PID(replace PID with the process ID).
- View running processes:
- User Management:
- Add a user:
sudo adduser username. - Delete a user:
sudo deluser username. - Change user:
su username.
- Add a user:
- Package Management (Linux-specific):
- Package managers install and manage software packages on Linux.
- Common package managers include
apt(Ubuntu, Debian),yum(Red Hat, CentOS), anddnf(Fedora).
- Getting Help:
- Use
manto access the manual pages for commands (e.g.,man ls). - Online resources like tutorials and forums are valuable for learning Unix.
- Use
Remember, Unix has a vast array of commands and features beyond what’s covered here. This tutorial provides a foundation for getting started, but continued learning and practice will help you become proficient in Unix. Good luck!