Basic Linux Commands

Basic commands used in a linux terminal

Command
Explanation
Example

cd

change directory

cd /home/kali/file_name.txt

mv

move a file/directory

mv file.txt /path/to/newlocation

pwd

print current working directory

pwd

grep

find the entered word

ls -l | grep ".txt"

ls

list files in current directory

ls

-l

Lists files in a long format, showing details such as permissions, ownership, size, and modification time.

ls -l

-a

Shows all files, including hidden files (those that start with a dot .).

ls -a

-h

Makes file sizes human-readable, often used with -l to show sizes in KB, MB, or GB.

ls -lh

mkdir

make directory

mkdir dir_name

rmdir

remove directory

rmdir dir_name

touch

create an empty file

touch file_name.txt

cat

see file content

cat file_name.txt

man

display manual for other commands

any command man

chmod

change mod of a file (rwx)

chmod +rwx file_name.txt

chown

change owner and group of a file

chown user:group file_name.txt

df

display available disk space

df -h

find

search for files in a directory hierarchy

find /path -type f -size +10M

tar

archive files

tar -czvf project.tar.gz project/

gzip

compres & decompres files/dirs

gzip file_name.txt

ssh

ssh connection request

ssh ip_addres port

curl

transfer data from/to server

curl -o downloaded_file.txt http://example.com/file.txt

ping

test connectivity

ping site.com

ifconfig

see network interface info

ifconfig

Last updated