Basic Unix Commands
This series is for people who love to enter the world of Linux. With the introduction of microservices, a lot of people started to show interest to learn Linux.
(Here we are not covering any advanced topics. It is for the people who are stepping into the world of Linux. Especially for those who wanted to learn Linux as a stepping stone for Kubernetes.)
tty
: Reveals the current terminal.whoami
: Displays the currently logged-in user.who am i
: Shows session information for the user.su
: Switches the user and changes the effective user ID and group ID.who
: Lists information about all user sessions on the system.w
: Displays session information along with server load average.last
: Shows historical data of logged-in user sessions.which
: Reveals the full path of a given command.uname
:uname -n
: Displays the node name (hostname).uname -r
: Shows the current running kernel version.uname -a
: Provides detailed system information.
echo
: Prints a string to the standard output.
Example: echo "Hello, welcome to the world of Linux."
In this lab, you will learn essential Unix commands to navigate your system, manage files and directories, and perform tasks.Let's dive in!
1. Navigating the Filesystem
ls
- List Files and Directories
ls
- List Files and DirectoriesUse the ls
command to display the contents of the current directory:
ls
pwd
- Show Current Working Directory
pwd
- Show Current Working DirectoryCheck your current working directory:
pwd
cd
- Change Directory
cd
- Change DirectoryNavigate between different folders:
cd /path/to/directory
2. File Operations
mkdir
- Create a Directory
mkdir
- Create a DirectoryCreate a new directory:
mkdir my_directory
cp
- Copy Files
cp
- Copy FilesMove files from one directory to another:
cp file.txt /path/to/destination/
mv
- Rename or Move Files
mv
- Rename or Move FilesRename or move files:
mv old_name.txt new_name.txt
rm
- Delete Files
rm
- Delete FilesRemove files or directories (use with caution):
rm file.txt
3. Text File Operations
cat
- Display File Contents
cat
- Display File ContentsView the contents of a text file:
cat file.txt
grep
- Search for Patterns
grep
- Search for PatternsSearch for specific strings in a file:
grep "pattern" file.txt
head
and tail
- Display First/Last Lines
head
and tail
- Display First/Last LinesShow the first or last lines of a text file:
head file.txt
tail file.txt
4. System Information
uname
- Get Basic OS Information
uname
- Get Basic OS InformationPrint information about the operating system:
uname -a
uptime
- System Uptime
uptime
- System UptimeFind out how long the system has been up:
uptime
5. Process Management
ps
- List Processes
ps
- List ProcessesDisplay running processes:
ps aux
kill
- Terminate a Process
kill
- Terminate a ProcessStop a process (use with caution):
kill PID
6. Networking
ifconfig
(or ip
) - Show IP Addresses
ifconfig
(or ip
) - Show IP AddressesView network interface information:
ifconfig
ping
- Check Host Reachability
ping
- Check Host ReachabilityTest if a remote host is reachable:
ping google.com
Remember to explore these commands further and practice using them. Feel free to experiment and learn more about Unix! 🚀
Feel free to customize this lab by adding more commands or exercises. If you have any questions or need assistance, feel free to ask!
Last updated