Introduction to UNIX
Course Overview
This comprehensive tutorial will take you through the fundamentals of the UNIX operating system. You'll learn essential command-line skills, file system navigation, shell scripting, and system administration basics.
- 8 Detailed Chapters covering UNIX fundamentals
- Command examples and practical exercises
- Best practices and productivity tips
- Final assessment for certification
Chapter 1: Introduction to UNIX
What is UNIX?
UNIX is a powerful, multi-user, multitasking operating system originally developed in the 1960s and 1970s at AT&T's Bell Labs. It forms the foundation for many modern operating systems, including Linux and macOS.
Why Learn UNIX?
- Most servers run on UNIX or UNIX-like systems
- Essential for developers, system administrators, and data scientists
- Powerful command-line tools for automation and productivity
- Understanding UNIX helps you understand how computers work at a fundamental level
UNIX Architecture
The UNIX system is divided into three main components:
- Kernel: The core of the operating system that interacts with hardware
- Shell: The command interpreter that processes user commands
- Utilities: Programs that provide additional functionality
Note: UNIX is case-sensitive. "File.txt" and "file.txt" are considered different files.
Chapter 2: File System Navigation
UNIX File System Structure
The UNIX file system is organized in a hierarchical tree structure with the root directory (/) at the top. Key directories include:
- /bin: Essential user command binaries
- /etc: System configuration files
- /home: User home directories
- /usr: User utilities and applications
- /var: Variable data like logs
Basic Navigation Commands
pwd
ls
ls -l
ls -a
cd /path/to/directory
cd ~
cd ..
Tip: Use the TAB key for auto-completion of file and directory names. This saves time and reduces typing errors.
Chapter 3: File Management
Creating and Managing Files
touch filename.txt
cp file1.txt file2.txt
cp -r dir1 dir2
mv oldname.txt newname.txt
mv file.txt /target/directory/
rm filename.txt
rm -r directoryname
Viewing File Contents
cat filename.txt
less filename.txt
head filename.txt
tail filename.txt
tail -f logfile.txt
Important: Be extremely careful with the rm command, especially with the -r and -f options. UNIX doesn't have a trash bin - deleted files are generally gone forever.
Chapter 4: File Permissions and Ownership
Understanding File Permissions
UNIX uses a permission system to control access to files and directories. There are three types of permissions:
- Read (r): Permission to read the file or list directory contents
- Write (w): Permission to modify the file or create/delete files in a directory
- Execute (x): Permission to execute the file or access files in a directory
Changing Permissions with chmod
chmod u+x filename
chmod go-w filename
chmod 755 filename
chmod 644 filename
Changing Ownership with chown
chown newowner filename
chgrp newgroup filename
chown owner:group filename
Note: Only the file owner or superuser (root) can change file permissions and ownership.
Chapter 5: Text Processing
Powerful Text Processing Tools
UNIX provides several powerful commands for processing text data:
Searching in Files with grep
grep "pattern" filename.txt
grep -i "pattern" filename.txt
grep -r "pattern" /path/to/directory
grep -v "pattern" filename.txt
Stream Editing with sed
sed 's/old/new/g' filename.txt
sed '/pattern/d' filename.txt
sed -i.bak 's/old/new/g' filename.txt
Tip: You can chain multiple UNIX commands together using pipes (|). For example: cat file.txt | grep "pattern" | sort | uniq
Chapter 6: Process Management
Viewing and Controlling Processes
In UNIX, a process is an instance of a running program. Here are essential process management commands:
Process Monitoring
ps
ps aux
top
htop
Process Control
long_running_command &
fg
Ctrl+Z
kill process_id
kill -9 process_id
Important: Be cautious when killing processes, especially with kill -9. This should be a last resort as it doesn't allow the process to clean up properly.
Chapter 7: Shell Scripting Basics
Introduction to Shell Scripting
Shell scripts are text files containing a sequence of commands that can be executed together. They are powerful tools for automation.
Basic Script Structure
echo "Hello, World!"
echo "Current directory: $(pwd)"
echo "Today is: $(date)"
Variables and Control Structures
name="John"
count=10
echo "Hello, $name"
echo "Count is $count"
if [ $count -gt 5 ]; then
echo "Count is greater than 5"
else
echo "Count is 5 or less"
fi
for i in {1..5}; do
echo "Iteration $i"
done
Tip: Make your scripts executable with chmod +x script.sh and always test them thoroughly before using them in production environments.
Chapter 8: Networking and System Information
Network Commands
UNIX provides several commands for network troubleshooting and information:
Essential Network Tools
ping example.com
netstat -tuln
ifconfig
ip addr
System Information Commands
uname -a
df -h
du -sh /path/to/directory
free -h
Note: Some networking commands may require superuser privileges to show all information or modify network configurations.
Certification & Assessment
After completing all chapters, you need to pass the final assessment to receive a certificate of completion. Scoring 50% or higher ensures certification.
The assessment will test your understanding of UNIX commands, file system navigation, permissions, process management, and basic shell scripting.