50 Linux Commands You Wish You Knew Earlier
Chaitanya Kurhe
?? Sr. TSE | AI Enthusiast | Virtual Assistant Developer | Conversational AI Developer | Prompt Expert | Elevating Customer Experiences | Former TSE @_VOIS | Technical Writer | Computer Science Grad | VIT'22 Alumnus
Unlocking the Secrets of Linux: 50 Commands That Will Change Your Life
Linux is a powerful and flexible operating system widely used in server environments, development, and various other applications. Mastering the Linux command line
1. ls - Lists directory contents.
```bash
ls -l /home/user
```
2. cd - Changes the current directory.
```bash
cd /var/www
```
3. mkdir - Creates a new directory.
```bash
mkdir new_directory
```
4. rmdir - Removes an empty directory.
```bash
rmdir old_directory
```
5. rm - Removes files or directories.
```bash
rm -r directory_to_remove
```
6. cp - Copies files or directories.
```bash
cp source_file destination_file
```
7. mv - Moves or renames files or directories.
```bash
mv old_name new_name
```
8. touch - Creates an empty file or updates the timestamp of an existing file.
```bash
touch newfile.txt
```
9. find - Searches for files in a directory hierarchy.
```bash
find /home/user -name "*.txt"
```
10. du - Estimates file space usage.
```bash
du -sh /var/log
```
### File Viewing and Editing
11. cat - Concatenates and displays file content.
```bash
cat file.txt
```
12. less - Views file content one page at a time.
```bash
less file.txt
```
13. head - Outputs the first part of files.
```bash
head -n 10 file.txt
```
14. tail - Outputs the last part of files.
```bash
tail -n 10 file.txt
```
15. nano - A simple text editor.
```bash
nano file.txt
```
16. vi - A powerful text editor.
```bash
vi file.txt
```
### File Permissions and Ownership
17. chmod - Changes file permissions.
```bash
chmod 755 script.sh
```
18. chown - Changes file owner and group.
```bash
chown user:group file.txt
```
19. chgrp - Changes group ownership.
```bash
chgrp group file.txt
```
20. ps - Reports a snapshot of current processes.
```bash
ps aux
```
21. top - Displays real-time system summary.
```bash
top
```
22. kill - Terminates processes by PID.
```bash
kill -9 1234
```
23. pkill - Terminates processes by name.
```bash
pkill firefox
```
24. bg - Resumes a suspended job in the background.
```bash
bg %1
```
25. fg - Brings a job to the foreground.
```bash
fg %1
```
26. jobs - Lists all jobs.
领英推荐
```bash
jobs
```
### Networking
27. ifconfig - Configures network interfaces.
```bash
ifconfig eth0
```
28. ping - Checks connectivity to a network host.
```bash
ping google.com
```
29. netstat - Displays network connections, routing tables, and interface statistics.
```bash
netstat -an
```
30. ss - Analyzes sockets.
```bash
ss -tuln
```
31. scp - Securely copies files between hosts.
```bash
scp file.txt user@remote:/path/to/destination
```
32. wget - Downloads files from the web.
```bash
```
33. curl - Transfers data from or to a server.
```bash
curl -O https://example.com/file.zip
```
34. uname - Prints system information.
```bash
uname -a
```
35. df - Reports file system disk space usage.
```bash
df -h
```
36. free - Displays memory usage.
```bash
free -m
```
37. uptime - Tells how long the system has been running.
```bash
uptime
```
38. dmesg - Prints kernel and boot messages.
```bash
dmesg
```
39. lshw - Lists hardware configuration.
```bash
sudo lshw -short
```
40. lsblk - Lists information about block devices.
```bash
lsblk
```
### User Management
41. adduser - Adds a new user.
```bash
sudo adduser newuser
```
42. usermod - Modifies a user account.
```bash
sudo usermod -aG sudo newuser
```
43. passwd - Changes user password.
```bash
passwd newuser
```
44. deluser - Removes a user.
```bash
sudo deluser olduser
```
45. groups - Shows which groups a user belongs to.
```bash
groups username
```
### Archiving and Compression
46. tar - Archives files.
```bash
tar -cvf archive.tar /path/to/directory
```
47. gzip - Compresses files.
```bash
gzip file.txt
```
48. gunzip - Decompresses files.
```bash
gunzip file.txt.gz
```
49. zip - Creates zip archives.
```bash
zip archive.zip file1 file2
```
50. unzip - Extracts zip archives.
```bash
unzip archive.zip
```