Commands

Linux commands and notes

Common commands

ls # list files and directories 
ls -la # will list all files including hidden items 
ld ~/(folder name)# to get to a folder without going through all folders 
mkdir # to make folders rmdir to remove folders 
mv # to move files 
locate # to find files…. sometimes you have to use updatedb to update to find files 
passwd # to change the password man : for manual pages
grep # searching within result or file
ps aux  # list proccesses
kill -9 processnumber # kill processes
touch #create files
sudo usermod -aG sudo <username> #Add user to sudoers

Network Commands

ifconfig # show network interfaces and information.
ip # updated version of ifconfig
ip n # gives you the arp table
ip r # gives you the routing table
iwconfig # for wireless configuration
arp -a # shows IP addresses and associated macs
netstat -ano # shows active network connections on the machine.
route # prints your routing table

Writing to Files

echo "hello" > hey.txt # will make a file name hey.txt containing the word hello
echo "hello" >> hey.txt # Will append the file.
Use nano,vi, or vim for editing files in prompt. User gedit for editing files in gui. 

Getting files from Github

git clone "repo url" # put these in /opt it is good practice or /tmp if you plan on using them temporarily.

PimpMyKali is a good script to use for setup.

Searching

List files and sub-folders that are non empty .

find . -type f -not -empty -ls #List files and subfolders that are non empty .
find . -type f -not -empty -exec cat {} \; #Read all files not empty in folder and subfolders.

find . -name thisfile.txt # Finding files by name.

Fix Path

export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Cron jobs

* * * * * root overwrite.sh # Indicates a file that runs every minute.

Last updated

Was this helpful?