Linux Terminal

 Certainly! The Linux terminal is a powerful tool that allows users to interact with the operating system through a command-line interface. Here's a guide to some basic to advanced Linux commands:


### Basic Commands:


1. **Navigation:**

   - `pwd`: Print the current working directory.

   - `ls`: List files and directories.

   - `cd <directory>`: Change directory.

   - `cd ..`: Move up one directory.


2. **File Operations:**

   - `touch <filename>`: Create an empty file.

   - `cp <source> <destination>`: Copy files or directories.

   - `mv <source> <destination>`: Move/rename files or directories.

   - `rm <filename>`: Remove a file.

   - `rm -r <directory>`: Remove a directory and its contents.


3. **Directory Operations:**

   - `mkdir <directory>`: Create a new directory.

   - `rmdir <directory>`: Remove an empty directory.


4. **Viewing File Content:**

   - `cat <filename>`: Display the entire file.

   - `more <filename>` or `less <filename>`: Display content one screen at a time.

   - `head <filename>`: Display the first few lines.

   - `tail <filename>`: Display the last few lines.


5. **File Permissions:**

   - `chmod <permissions> <file>`: Change file permissions.

   - `chown <user>:<group> <file>`: Change file ownership.


### Intermediate Commands:


6. **Searching:**

   - `grep <pattern> <filename>`: Search for a pattern in a file.

   - `find <directory> -name <filename>`: Find files in a directory.


7. **Process Management:**

   - `ps`: Display information about active processes.

   - `kill <PID>`: Terminate a process.

   - `top` or `htop`: Display a dynamic view of system processes.


8. **Text Editing:**

   - `nano <filename>` or `vim <filename>`: Text editors for creating or editing files.


9. **Archives and Compression:**

   - `tar -cvzf <archive.tar.gz> <directory>`: Create a compressed tarball.

   - `tar -xvzf <archive.tar.gz>`: Extract files from a tarball.


### Advanced Commands:


10. **System Information:**

    - `uname -a`: Display system information.

    - `df -h`: Show disk space usage.

    - `free -m`: Display memory usage.


11. **Networking:**

    - `ifconfig` or `ip addr show`: Display network interfaces.

    - `ping <hostname>`: Check network connectivity.

    - `netstat -an`: Display network connections.


12. **User Management:**

    - `useradd <username>`: Add a new user.

    - `passwd <username>`: Change user password.

    - `usermod -aG <group> <username>`: Add a user to a group.


13. **Package Management (apt for Debian/Ubuntu):**

    - `sudo apt update`: Update package lists.

    - `sudo apt upgrade`: Upgrade installed packages.

    - `sudo apt install <package>`: Install a new package.

    - `sudo apt remove <package>`: Remove a package.


These commands should provide a good starting point for navigating and managing a Linux system. Remember to use the manual pages (`man`) for more detailed information about each command and its options. For example, `man ls` will display the manual for the `ls` command.


System Based Commands

unameDisplays system information: kernel version, machine type, and more.
uname -rDisplays the running Linux kernel's release version.
uptimeShows current time, system uptime, users, and load averages.
hostnameShows the system hostname.
hostname -iDisplays the IP address of the current host.
last rebootShows last reboot times and durations in logs.
dateDisplays the current date and time information.
timedatectlDisplays detailed system clock and time zone information.
calDisplays a simple calendar of the current month.
wShows who is logged on and their activity.
whoamiDisplays the username of the current user.
finger usernameDisplays information about a user named 'username'.

Hardware Based Commands

dmesgDisplays messages from the kernel's ring buffer.
cat /proc/cpuinfoDisplays detailed information about the CPU.
cat /proc/meminfoDisplays detailed system memory usage information.
lscpuLists information about the CPU.
lshwLists detailed hardware configuration of the system.
lsblkLists information about all available block devices.
free -mShows system memory usage in megabytes.
lspci -tvDisplays PCI devices in tree format, verbosely.
lsusb -tvShows USB devices as a tree, verbosely.
dmidecodeDisplays hardware information from system BIOS
hdparm -i /dev/sdaDisplays information of disk /dev/sda.
badblocks -s /dev/sdaChecks /dev/sda for bad blocks, showing progress.

User Management Commands

idDisplays the user's UID, GID, and groups.
lastShows list of last logged-in users.
whoDisplays who is currently logged in.
groupadd adminCreates a new user group named admin.
adduser SamCreates a new user account named Sam.
userdel SamDeletes the user account named Sam.
usermodModifies properties of an existing user account.

File Commands

ls -alLists all files, detailed information, in long format.
pwdDisplays the present working directory's path.
mkdir dir1Creates a new directory named dir1.
rm file1Deletes the file named file1.
rm -f file2Forcefully deletes the file named file2.
rm -r dir1Recursively removes directory dir1 and its contents.
rm -rf dir1Forcefully deletes directory dir1 and its contents.
cp file1 file2Copies file1, creating or overwriting file2.
cp -r dir1 dir2Copies dir1 to dir2, including subdirectories.
mv file1 file2Renames or moves file1 to file2.
ln -s /path/to/file_name link_nameCreates symbolic link named link_name to file_name.
touch file1Creates an empty file named file1.
cat > file1Creates/overwrites file1, awaiting standard input.
more file1Displays file1 content, paginating through output.
head file1Displays the first ten lines of file1.
tail file1Displays the last ten lines of file1.
gpg -c file1Encrypts file1 with symmetric cipher using passphrase.
gpg file2.gpgDecrypts file2.gpg, prompting for the passphrase.
wcCounts words, lines, and characters in files.
xargsExecutes commands with piped or file-provided arguments.

Process Related Commands

psDisplays a snapshot of current processes.
ps aux | grep telnetDisplays running telnet processes with details.
pmapShows memory map of a process.
topDisplays dynamic real-time view of running tasks.
kill 1234Terminates the process with PID 1234.
killall procKills all processes named 'proc'.
pkill process-nameTerminates processes with the name.
bgResumes suspended jobs in the background
fgBrings a suspended job to foreground
fg nBrings job number 'n' to foreground.
lsofLists all open files and processes.
renice 19 PIDChanges priority of process with given PID.
pgrep firefoxDisplays Process ID(s) for firefox processes.
pstreeDisplays a tree of running processes.

File Permission Commands

chmod 644 /data/test.c      Sets the permissions of the file /data/test.c to be read/write for the owner, and read-only for the group and others.
chmod 755 /dir1      Assigns read, write, and execute permissions to the owner, and read and execute permissions to the group and others for the directory /dir1.
chown bob:devops filename      Changes file 'filename' ownership to 'bob' and 'devops'.
chown ownername:groupname directory  Change owner and group of the directory.

Network Commands

ip addr show                   Displays all network interfaces and their information.
ip address add 192.168.0.1/24 dev eth0   Assigns IP address 192.168.0.1 to interface eth0.
ifconfig                            Shows network interfaces and their configuration.
ping host                       Sends ICMP packets, measures round-trip time to "host".
whois domain                 Retrieves and displays domain's registration information.
dig domain                      Queries DNS, provides domain's DNS information.
dig -x host                   Resolves IP address to hostname, shows DNS information.
host google.com          Performs an IP lookup for the domain name
wget file_path            Downloads file from specified path.
netstat  Displays various network-related information and statistics.
ssDisplay information about network sockets.

Compression/Archives Commands

tar -cf backup.tar /home/ubuntuCreates a tar archive of /home/ubuntu directory.
tar -xf backup.tar             Extracts files from "backup.tar" archive.
tar -zcvf backup.tar.gz /home/ubuntu  Creates compressed "backup.tar.gz" archive of "/home/ubuntu"
gzip file1 Compresses "file1" into "file1.gz", original is removed.

Install Packages Commands

rpm -i pkg_name.rpm           Installs the package "pkg_name.rpm" using RPM Package Manager.
rpm -e pkg_name                     Uninstalls the specified RPM package.
dnf install pkg_nameInstalls the specified package using DNF.
pacman -S pkg_nameInstalls the specified package using Pacman.

Install Source (Compilation)

./configureChecks system compatibility and generates makefile for software installation.
makeCompiles code by following instructions in the Makefile.
make installInstalls compiled code into specified system locations.

Search Commands

grep pattern file                           Search for a given pattern within the file.
grep -r pattern dir1                             Recursively searches for the specified "pattern" within the "dir1" directory and its subdirectories
locate fileFinds files named "file" using prebuilt database.
find /home -name index             Searches "/home" directory for files named "index" recursively.
find /home -size +10000kFinds files over 10000k size in /home directory.

Login Commands

ssh user@hostname Initiates SSH connection to specified hostname.
ssh -p port_number user@hostname   Initiates SSH connection using specific port.
Connect to the host via telnet default port 23Securely connect to the system via SSH default port 22
telnet host Connect to the host via telnet default port 23.

File Transfer Commands

scp file.txt remoteuser@remote_host:/remote/directoryCopies file.txt to remote host's specified directory.
rsync -a /home/ubuntu /backup/ Synchronizes content from source directory to destination directory,preserving attributes.
rsync -a /var/www/web/ user@remote_host:/backup/web_backup/Synchronizes local directory to remote, preserving attributes.

Disk Usage Commands

df  -h                           Displays human-readable disk space usage for all mounted filesystems.
df  -i                          Displays inode usage information for all mounted filesystems.
fdisk  -l                    Lists all partitions and their information on all drives.
du -sh /dir1                       Displays summary of total disk usage size of /dir1, human-readable.
findmnt                      Displays a list of all mounted filesystems and their properties.
mount device-path mount-pointMounts the device at the specified filesystem mount point.

Directory Traverse Commands

cd ..             Navigate to the parent directory.
cd                Changes the current directory to the user's home.
cd /mnt Changes the current directory to "/mnt"




Comments

Popular posts from this blog

[[ ROYAL CAR ]] CHANGE PASSWORD - DYNAMIC BANNER - MULTIPLE IMAGE - LOGIN LOGOUT BACK BUTTON MIDDLEWARE STOP - MAIL DIRECTLY WITH FEEDBACK WITH SAVE IN SQL DB - ADMIN REPLY EXISTING MAILS - DYNAMICALLY CSS CHANGE

Sahari