Basic Linux commands

Raj Upadhyay
2 min readSep 23, 2020

--

File Commands

  1. Directory Listing
ls = directory listingls -al = formatted listing with hidden files

2. Change Directory

cd dirname

3. Current Working Directory

pwd

4. Create Directory

mkdir dirname

5. Delete Files/directory

rm file        => delete file
rm -r dirname => delete directory
rm -f file => force remove file
rm -rf dirname => force remove directory

6. Copy one file to another

cp file1 file2 => copy file1 to file2

7. Rename File

mv file1 file1_new_name => rename file1 to file1_new_name

8. Output Content of File

more filename => output content of file in terminal
less filename => output content of file in terminal
head filename => output first 10 lines of file in terminal
tail filename => output last 10 lines of file in terminal

9. cat

cat > file   => place standard input into file

SSH commands

ssh user@host               => connect to HOST
ssh -p portnumber user@host => connect to HOST using a specific port

Network Commands

ping  hostname   => ping particular HOST
whois domain => get whois for Domain
dig domain => get DNS for Domain
dig -x host => reverse lookup host

wget

wget file_path    => download file
wget -c file_path => contiune stopped download
wget -r file_path => recursively download files from url

System Info

  1. Date and calendar
date => show current date/time
cal => show this month's calendar

2. Whoami

whoami   => who are you logged in as
uname -a => show kernel config

3. Cup and Memory Info

cat /proc/cpuinfo => cupinfo
cat /proc/meminfo => memory info

4. Man Command

man command => show manual for command
man cat => show manual for cat command

5. Disk space info

df     => show disk usage
du => show directory space usage
du -sh => human readbale size in GB
free => show memory & swap usage

--

--

Raj Upadhyay
Raj Upadhyay

Written by Raj Upadhyay

DFIR Consultant || #LoveToPlayCTF #infosec #cybersecurity #4n6

No responses yet