0% found this document useful (0 votes)
1 views

Linux Commands With Examples

This document provides a comprehensive list of basic and advanced Linux commands along with examples for each. Key commands include 'pwd' for printing the current directory, 'ls' for listing files, and 'grep' for searching patterns in files. Additional commands cover file management, process control, and system monitoring.

Uploaded by

fakehecker23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Linux Commands With Examples

This document provides a comprehensive list of basic and advanced Linux commands along with examples for each. Key commands include 'pwd' for printing the current directory, 'ls' for listing files, and 'grep' for searching patterns in files. Additional commands cover file management, process control, and system monitoring.

Uploaded by

fakehecker23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Basic Linux Commands with Examples

pwd - Prints the current working directory.

Example: pwd

ls - Lists files and directories.

Example: ls -l

cd - Changes the current directory.

Example: cd /home/user

mkdir - Creates a new directory.

Example: mkdir new_folder

rmdir - Removes an empty directory.

Example: rmdir old_folder

touch - Creates a new file.

Example: touch file.txt

rm - Deletes files or directories.

Example: rm file.txt

cp - Copies files or directories.

Example: cp source.txt dest.txt

mv - Moves or renames files.

Example: mv oldname.txt newname.txt

cat - Displays contents of a file.

Example: cat file.txt

echo - Displays a line of text.

Example: echo 'Hello, World!'

clear - Clears the terminal.

Example: clear

man - Displays the manual for a command.


Example: man ls

whoami - Displays current user.

Example: whoami

chmod - Changes file permissions.

Example: chmod 755 file.sh

chown - Changes file ownership.

Example: chown user:user file.txt

exit - Closes the terminal.

Example: exit
Advanced Linux Commands with Examples

grep - Searches for patterns in files.

Example: grep 'main' file.c

find - Finds files/directories.

Example: find . -name '*.txt'

awk - Processes and analyzes text files.

Example: awk '{print $1}' file.txt

sed - Edits streams of text.

Example: sed 's/old/new/g' file.txt

tar - Archives files.

Example: tar -cvf archive.tar file1 file2

gzip/gunzip - Compresses/decompresses files.

Example: gzip file.txt

top - Displays running processes.

Example: top

ps - Shows running processes.

Example: ps aux

kill - Terminates processes.

Example: kill 1234

df - Shows disk space.

Example: df -h

du - Shows directory usage.

Example: du -sh *

ssh - Connects to remote host.

Example: ssh [email protected]

scp - Securely copies files.


Example: scp file.txt user@host:/path

wget - Downloads from web.

Example: wget http://example.com/file.txt

curl - Transfers data from/to server.

Example: curl https://example.com

cron - Schedules tasks.

Example: crontab -e

journalctl - Views logs.

Example: journalctl -xe

You might also like