Skip to main content

Manipulate Files & Directories In Kali Linux - Common Commands

 

  Manipulate Files & Directories


Navigate directories

pwd: Display path of current directory you’re in

ls: List all files and folders in the current directory
ls -la: List detailed list of files and folders, including hidden ones

 

Change to a specific directory

cd: Change to home directory
cd /user/Desktop: Change to a specific directory called Desktop
cd .. : Move back a directory

Create a directory/folder

mkdir <dir>: Create a new directory
mkdir /home/Desktop/dir: Create a directory in a specific location

 

Create and edit files

touch <file>: Create an empty file
nano <file>: Edit an existing file or create it if it doesn’t exist.
Alternatives to nano text editor: vim, emacs

 

Copy, move and rename files and directories

cp <file1> <file2>: Create a copy of a file
cp -r <dir1> <dir2>: Create a copy of a directory and everything in it
cp <file> /home/Desktop/file2: Create a copy of a file in a different directory and name it file2.

mv <file> /home/Desktop: Move a file to a specific directory (overwrites any existing file with the same name)
mv <dir> /home/Desktop: Move a directory to another location
mv <dir1> <dir2>: Rename a file OR directory (dir1 -> dir2)

 

Delete files

rm <file>: Delete a file
rm -f <file>: Force delete a file
Careful now..

rm -r <dir>: Delete a directory and its contents
rm -rf <dir>: Force delete a directory and its contents 

Be careful when using this command, it will delete everything inside the directory

  

Network Utilities

ping <host>: Ping a host
whois <domain/IP>: Get whois information about a domain or IP
dig <domain/IP>: Get DNS information
nslookup: <NS>: Get nameserver information

ifconfig: Configure/display network interfaces
iwconfig: Configure/display wireless network interfaces

netstat -r: Display kernel IP routing tables
netstat -antp: Check for established and listening ports/connections

arp -a: Display ARP cache tables for all interfaces

 

Secure File Transfer - (SCP)

Transfer files FROM the local system TO a remote host (Local > Remote)
scp /path/to/file user@host:/path/to/dest

Transfer files FROM a remote host TO the local system (Remote > Local)
scp user@host:/path/to/file /path/to/dest

Transfer directories and everything within it
scp -r /path/to/dir user@host:/path/to/dest

Transfer all files that match a specific filetype
scp /path/to/*.txt user@host:/path/to/dest

Transfer local public SSH public key to remote host
cat ~/.ssh/id_rsa.pub | ssh user@host 'cat >> .ssh/authorized_keys'

  

Output and analyze files

cat <file>: Display/output the contents of a file
less <file>: Display the contents of a file with scroll (paginate) ability (press q to quit)

head <file>: Display the first ten lines in a file
head -20 <file>: Display the first 20 lines in a file
tail <file>: Display the last ten lines in a file
tail -20 <file>: Display the last 20 lines in a file

diff <file1> <file2>: Check the difference between two files (file1 and file2)

 

System & User Information

cal: Display monthly calendar

date: Check date and time
uptime: Check system uptime and currently logged in users

uname -a: Display system information.
dmesg: Display kernel ring buffer

poweroff: Shutdown system
reboot: Reboot system

View disk and memory usage

df -h: Display disk space usage
fdisk -l: List disk partition tables
free: Display memory usage

cat /proc/meminfo: Display memory information
cat /proc/cpuinfo:
Display cpu information

View user information

whoami: Output your username
w: Check who’s online

history: View a list of your previously executed commands

View last logged in users and information

last: Display last login info of users
last <user>: Display last login info of a specific user

finger <user>: Display user information

 

Installing & Upgrading Packages

Search for packages

apt-cache pkgnames: List all available packages
apt search <name>: Search for a package and its description
apt show <name>: Check detailed description of a package

Install packages

apt-get install <name>: Install a package
apt-get install <name1> <name2>: Install multiple packages

Update upgrade & cleanup

apt-get update: Update list of available packages
apt-get upgrade: Install the newest version of available packages
apt-get dist-upgrade: Force upgrade packages.
apt-get autoremove: Remove installed packages that are no longer needed
apt-get clean: Free up disk space by removing archived packages

Delete package's

apt-get remove: Uninstall a package
apt-get remove --purge: Uninstall a package and remove its configuration files

Processes & Job Management

top: Display running processes & system usage in real-time.

ps: Display currently running processes
ps -u <user>: Display currently running processes of a user

kill <PID>: Kill a processes by PID #.
killall <processes>: Kill all processes with specified name.

Start stop & resume jobs

jobs: Display the status of current jobs
jobs -l: Display detailed info about each job
jobs -r: Display only running jobs

bg: View stopped background jobs or resume job in the background
fg: Resume recent job in the foreground
fg <job>: Bring specific job to the foreground.

 

Download a full website:

wget -r domain.com

 

Keyboard Shortcuts



CTRL + L   
Clear terminal screen


CTRL + D
Log out of current session


CTRL + C
Stop (halt) currently running command/processes


CTRL + Z   
Suspend (pause) currently running command/processes


CTRL + W
Delete the last word/argument


CTRL + E
Jump (skip) to the very LAST line


CTRL + A
Jump (skip) to the very FIRST line


CTRL + F
Move cursor one letter forward


CTRL + B
Move cursor one letter backward





CTRL + U
Cut (copy) everything BEFORE the cursor


CTRL + K
Cut (copy) everything AFTER the cursor


CTRL + Y
Paste previously copied text



clear   
Clear terminal screen

reset
Fix display errors

exit
Exit (log out) current session

tab
Auto-complete

!!   
Repeat last command

sudo !!   
Repeat last command as sudo (admin/root) user
























Comments

Popular posts from this blog

FIXED - No Connection After Changing MAC Address In Kali Linux!

No Connection After Changing MAC Address In Kali Linux - Fixed! (VirtualBox Fix)   Problem: You run commands to change your MAC, and then your connection drops. Fix:   1) Power off Kali & VMBox and then restart VMBox 2) Go to settings in VMbox and create another connection (bridged or NAT) 3) Now fire up Kali again 4) Run the following commands in terminal --------------------------------------------------------------- sudo macchanger -s eth0 - check your MAC address sudo ifconfig eth0 down - knock off your connection sudo macchanger -r eth0 - Set MAC to random 5) Click top right of home screen and switch to second saved connection  6) Open new terminal & run the following commands: ping bing.com                           - check connection sudo macchanger -s eth0      - check MAC address Now you should see that your connection is working and your MAC address is different.   Commands to change MAC address can be found here .   If your still seeing issues

How To Install & Run SocialPhish On Kali Linux 2021 - Working

  How To Install & Run SocialPhish Commands are: git clone https://github.com/xHak9x/SocialPhish cd SocialPhish ls chmod +x socialphish.sh ./socialphish.sh  git clone https://github.com/xHak9x/SocialPhish: downloads git cd SocialPhish: Changes directory ls: Lists folders in current directory chmod +x socialphish.sh: Gives tool permissions ./socialphish.sh: Start / run tool command     If you face problems, go to ngrok.com and create a free account  Then go to authorization token and install with command given  If you need more help let me know I can post some common fixes. Sometimes some of the pages wont work, you just have to get used to it. This works great for targeting one person alone, but after they connect and you get your info, the tool will have to be reset and a new link created to run again. There is another way which works with blackeye tool, which stays live & captures login's for as long as the tool is open (or the server is up). There is a common proble

Blackeye - Kali Linux DOWNLOAD & FIX For No Link Showing 2021!

  How To Install & Run Blackeye.sh (+FIX for no link showing issue) This is a Phishing tool. Phishing is a type of hacking also called credential harvesting. It creates fake websites for victims to login which saves their login info which includes IP, User-Agent, Username and Password to a file in the computer running Blackeye. Usage of BlackEye for attacking targets without prior mutual consent is illegal. It's the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program. Only use for educational purposes. Commands: cd Desktop/ git clone https://github.com/An0nUD4Y/blackeye.git cd blackeye/ ls chmod +x blackeye.sh sudo ./blackeye.sh     Fix: No Link Showing: 1) Load up the tool with sudo ./blackeye.sh command 2) Now open a new terminal and enter the following commands: cd blackeye cd sites ls                 <-- you will now see the sit