0% found this document useful (0 votes)
9 views10 pages

All About Linux

all about linux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

All About Linux

all about linux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

GOVERDHAN

All About Linux: Essential


Commands, File Permissions,
and File System Structure by
GOVERDHAN

Kali Linux, a Debian-based distribution, is widely used for penetration testing and
security auditing. To leverage its full potential, a comprehensive understanding of
the Linux file system, essential commands, and file permissions is necessary.

Basic Commands in Kali Linux

File Management Commands


1. Listing Files and Directories

ls : Lists files in the current directory.

ls -al : Lists all files, including hidden ones, with detailed information.

ls -lt : Lists files sorted by modification time.

2. Directory Navigation

cd [dir] : Changes the current directory to dir .

cd : Changes to the home directory.

pwd : Prints the current working directory.

3. File and Directory Operations

mkdir [dir] : Creates a directory named dir .

rmdir [dir] : Deletes an empty directory named dir .

rm [file] : Deletes the file named file .

rm -r [dir] : Recursively deletes the directory dir and its contents.

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 1
: Creates a new empty file named
touch [file] file or updates its
timestamp if it exists.

cp [source] [destination] : Copies the file or directory from source to


destination .

mv [source] [destination] : Moves or renames the file or directory from


source to destination .

4. Viewing and Editing Files

cat [file] : Displays the contents of file .

more [file] : Displays the contents of file one page at a time.

head [file] : Displays the first 10 lines of file .

tail [file] : Displays the last 10 lines of file .

nano [file] : Opens file in the Nano text editor.

vim [file] : Opens file in the Vim text editor.

5. Finding Files and Directories

find [directory] -name [filename] : Searches for filename within directory .

locate [filename] : Finds all instances of filename on the system.

System Information Commands


1. System and Hardware Information

uname -a : Displays detailed information about the kernel.

lsb_release -a : Shows Linux distribution information.

df -h : Reports file system disk space usage in a human-readable format.

free -h : Displays free and used memory in a human-readable format.

top : Displays real-time system processes and resource usage.

htop : An enhanced version of top with an improved user interface.

2. User Information

whoami : Displays the username of the current user.

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 2
id : Displays user identity information.

w : Shows who is logged on and what they are doing.

finger [user] : Displays information about user .

3. Process Management

ps : Lists running processes.

kill [pid] : Terminates the process with the given process ID ( pid ).

killall [process_name] : Terminates all processes with the name process_name .

bg : Resumes a stopped job in the background.

fg : Brings a background job to the foreground.

Package Management Commands


1. APT Package Manager

sudo apt update : Updates the list of available packages and their versions.

sudo apt upgrade : Installs newer versions of installed packages.

sudo apt install [package_name] : Installs the specified package.

sudo apt remove [package_name] : Removes the specified package but keeps
configuration files.

sudo apt purge [package_name] : Removes the specified package along with its
configuration files.

apt list --installed : Lists all installed packages.

dpkg -l | grep [search_name] : Searches installed packages based on the


name.

File Permissions in Kali Linux

Understanding File Permissions


File permissions in Linux are crucial for system security and data integrity. Each
file and directory has three types of permissions (read, write, and execute) for
three categories of users (owner, group, and others).

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 3
1. Permission Types

Read (r): Permission to read the contents of the file.

Write (w): Permission to modify the file.

Execute (x): Permission to execute the file (applicable to scripts and


binaries).

2. User Categories

Owner (u): The user who owns the file.

Group (g): The group that owns the file.

Others (o): All other users.

3. Viewing File Permissions

ls -l [file] : Displays the detailed list of files including permissions.

Example output: rwxr-xr-- 1 user group 4096 Jan 1 00:00 file

: Type of file ( for regular files, d for directories).

rwxr-xr-- : Permission string (owner, group, others).

Modifying File Permissions


1. Using chmod Command

chmod [permissions] [file] : Changes the permissions of the file.

Symbolic Mode: Permissions are represented by letters.

chmod u+x [file] : Adds execute permission for the owner.

chmod g-w [file] : Removes write permission for the group.

chmod o=r [file] : Sets read-only permission for others.

Numeric Mode: Permissions are represented by an octal number.

chmod 755 [file] : Sets permissions to rwxr-xr-x (owner:


read/write/execute, group: read/execute, others: read/execute).

chmod 644 [file] : Sets permissions to rw-r--r-- (owner: read/write,


group: read, others: read).

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 4
2. Using chown Command

chown [owner] [file] : Changes the owner of the file.

chown [owner]:[group] [file] : Changes the owner and group of the file.

Example: chown root:root [file] : Sets the owner to root and the group to
root .

3. Using chgrp Command

chgrp [group] [file] : Changes the group of the file.

Example: chgrp staff [file] : Sets the group of the file to staff .

Linux File System


The Linux file system is structured hierarchically, with the root directory ( / ) at the
top. Understanding the directory structure is key to navigating and managing a
Linux system effectively.

Key Directories in the Linux File System


1. / (Root)

The top-level directory of the file system hierarchy.

2. /bin

Contains essential binary executables.

3. /boot

Contains boot loader files.

4. /dev

Contains device files.

5. /etc

Contains configuration files.

6. /home

Contains user home directories.

7. /lib

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 5
Contains shared libraries and kernel modules.

8. /media

Contains mount points for removable media.

9. /mnt

Temporarily mounts filesystems.

10. /opt

Contains optional software packages.

11. /proc

Contains process and system information.

12. /root

Home directory for the root user.

13. /sbin

Contains system binaries.

14. /srv

Contains data for services provided by the system.

15. /tmp

Contains temporary files.

16. /usr

Contains user binaries and read-only data.

17. /var

Contains variable data files.

File System Commands


1. Mounting and Unmounting File Systems

mount [device] [mount_point] : Mounts a file system.

umount [device] : Unmounts a file system.

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 6
2. Checking File System Disk Usage

df -h : Reports file system disk space usage in a human-readable format.

du -sh [directory] : Summarizes disk usage of the specified directory.

3. File System Integrity Check

fsck [device] : Checks and repairs the file system on the specified device.

4. Creating and Managing Partitions

fdisk [device] : Partition table manipulator for Linux.

mkfs.[type] [device] : Creates a file system of the specified type on the


device.

Practical Examples
1. Navigating the File System

cd /home/user
pwd
ls -a

2. Managing Files and Directories

mkdir /home/user/test
cd /home/user/test
touch example.txt
echo "Hello, World!" > example.txt
cat example.txt
cp example.txt example_copy.txt
mv example_copy.txt new_name.txt
rm new_name.txt

3. Changing File Permissions

chmod 755 example.txt


ls -l example.txt

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 7
chmod u+w example.txt
chmod g-w example.txt
chmod o=r example.txt

4. Modifying Ownership and Group

sudo chown user:staff example.txt


ls -l example.txt
sudo chgrp users example.txt

5. Mounting and Unmounting File Systems

sudo mount /dev/sdb1 /mnt


df -h
sudo umount /mnt

Conclusion
Mastering the basic commands, file permissions, and file system structure in Kali
Linux is essential for effective system administration and security. These skills
provide a strong foundation for managing files, securing data, and maintaining the
overall health of the system.

FOLLOW:

https://www.linkedin.com/in/wh04m1i/

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 8
wh04M1i - Overview
Founder of the art act and foxfoster | Top 1% TryHackMe |
Cybersecurity Enthusiast | Pentester | CTF Player | OSINT |
Digital Forensics | Programmer - wh04M1i
https://github.com/wh04M1i

Goverdhan Kumar – Medium


Read writing from Goverdhan Kumar on Medium. Every day,
Goverdhan Kumar and thousands of other voices read,
write, and share important stories on Medium.
https://medium.com/@wh04m1i

Instagram (@who4m1i)
Instagram photos and videos

https://www.instagram.com/who4m1i

All About Linux: Essential Commands, File Permissions, and File System Structure by GOVERDHAN 9

You might also like