Basic Linux Command
Maded by Bismoy Ghosh.
Introduction
Linux is a powerful operating system that is widely used for development, cybersecurity, and server management. Understanding basic Linux commands is essential for navigating the file system, managing processes, handling networking, and performing system administration tasks. This research document explores fundamental Linux commands and their applications.
---
1. Files & Navigating the Linux Filesystem
Navigating through files and directories in Linux is an essential skill. Some of the key commands include:
Listing Files:
ls – Lists files and directories.
ls -l – Displays a detailed list with permissions and timestamps.
ls -la – Lists all files, including hidden ones.
Navigating Directories:
cd dir – Changes to a specific directory.
cd .. – Moves to the parent directory.
cd ~ – Navigates to the home directory.
File and Directory Management:
pwd – Prints the current working directory.
mkdir dir – Creates a new directory.
rm file – Deletes a file.
rm -r dir – Removes a directory and its contents.
cp file1 file2 – Copies files.
mv file1 file2 – Moves or renames files.
File Viewing and Editing:
touch file – Creates or updates a file.
cat file – Displays file contents.
tail -f file – Shows file contents in real-time.
---
2. System Information Commands
Linux provides several commands to gather system details:
date – Displays the current date and time.
uptime – Shows how long the system has been running.
whoami – Identifies the current user.
w – Displays who is online.
cat /proc/cpuinfo – Shows CPU information.
cat /proc/meminfo – Displays memory details.
free – Provides memory and swap usage.
du -sh – Displays the disk usage of a directory.
df – Shows disk space usage.
uname -a – Displays system kernel details.
---
3. Networking Commands
Networking in Linux is managed through various commands:
Host and Domain Information:
ping host – Checks network connectivity.
whois domain – Retrieves WHOIS information.
dig domain – Resolves domain names.
dig -x host – Performs reverse lookup.
File Downloading:
wget file – Downloads a file from the web.
wget -c file – Resumes an interrupted download.
curl url – Fetches a web page.
Remote Connections:
ssh user@host – Connects to a remote host via SSH.
ssh -p port user@host – Specifies an SSH connection using a custom port.
---
4. Compressing & Archiving Files
File compression and archiving are essential for storage and backups.
Creating Archives:
tar cf file.tar files – Creates an archive.
tar xf file.tar – Extracts an archive.
tar tf file.tar – Lists archive contents.
Compression Options:
-c – Create an archive.
-x – Extract files.
-z – Use gzip compression.
-j – Use bzip2 compression.
-v – Verbose output.
---
5. Managing Permissions
File and directory permissions control access levels for users.
Understanding Permission Values:
4 – Read (r).
2 – Write (w).
1 – Execute (x).
Changing Permissions:
chmod 777 file – Grants full permissions.
chmod 755 file – Read and execute access for all, but write access only for the owner.
---
6. Process Management
Linux allows users to manage system processes efficiently.
ps – Displays currently running processes.
top – Provides a dynamic view of processes.
kill pid – Terminates a process by ID.
killall proc – Stops all processes with a given name.
---
7. Other Useful Commands
grep pattern file – Searches for a pattern in files.
grep -r pattern dir – Recursively searches within directories.
locate file – Finds a file's location.
which app – Shows the location of an application.
man command – Displays the manual page for a command.
---
Conclusion
Mastering these basic Linux commands is crucial for efficient system management. From file handling to networking, c
ompression, permissions, and process management, Linux offers powerful tools for users at all levels. Whether you're a beginner or an advanced user, these commands form the foundation of effective Linux usage.
.jpeg)
Comments
Post a Comment