Bash and Linux Commands


Basic Shell Management commands

sudo - super user do

sudo su - got to root

exit - leave root

su - switch user

sudoers file

cd /root

man - display command manual

--help - display command help

adduser

chmod 777 or Chmod +x - give full permission or make file executable

./ - to run a file

switch to root command - sudo su

exit root - exit or su [machine name] command

install tools in /opt folder

cat /etc/shells : to find list of shells on a system

Network commands

ifconfig

arp

netstat

route

ip : a, n

Netcat command to listen nc -lvnp [port num]

thunar

Install Files/Update

sudo apt update && sudo apt upgrade

/opt - where to save download files

pimpmy kali - to install update

apt install gedit - text editor

To remove programs

apt list --installed Scroll through the list of installed packages in the Terminal window to find the one you want to uninstall. Note the full name of the package.

sudo apt purge [program name]

To update and upgrade packages

sudo apt full-upgrade -y OR run as root - sudo apt up ate apt upgrade

OR use pimpmykali

File Commands

mkdir - make new folder/directory

ls - List files and directories

ls -la - list all files + hidden folders /files hidden files or folders starts with .

cd - change directory to root folder

cd . - current directory

cd .. - parent directory

open . - open files or folder

pwd - print current directory

whoami - display current users name

touch file.txt - create new file named file.txt

ls -la - show all files in directory

start . - open current folder/directory

explorer . - open current folder/directory

cd Desktop/new-folder - navigating long path

Using find command find /directory -name *.txt(anything.txt)

file - check for a file type

less: used to read contents of text file one page (one screen) per time

more: reads files and displays the text one screen at a time

locate : to find file and directories.

File Management Commands

touch - create new file

>: write to new file

>>: append to file

cat - list contents of file

cat * : list all files

nano - edit file

  • ctrl o : save changes

  • ctrl x : exit (Yes / No, before exiting)

clear - clear terminal

tab - autocomplete command

echo - print to terminal / copy to another file

rm - remove files

rm -rf - remove folder

--help - help on specific commands

ps : list running process

pgrep explorer : get process for explorer

Git

Repository - folder/place where your project is kept git - tool that tracks changes in code in real time Github - A website to hots your repositories online

Git commands

clone - bring a repository hosted somewhere like github into a folder on your local machine.

add - track your files in Git

commit - save your files in Git

-m - message (what and why of the commit you make)

push - Upload Git commits to a remote repo, like Github

git push -u origin master (can just use git push after this)

pull - Download changes from remote from renote repo to your local machine, opposite of push.

git init - creates new empty repo

git remote add origin - add files in local pc to Github

git branch - to see which branch you are on

git checkout -b [branch name] - to create a new branch

git diff [branch name] - shows difference between branches

git merge - merge changes between two branches

git branch -d [branch name]

git commit -am [message] - add changes to file already commited/modified files

git reset [name of files to reset] - undo changes to files

git reset HEAD~1 - undo commits

git hash-object

git cat-file git mktree

blob - rep single file in git object

tree - rep folders

find help on all tools https://www.kali.org/tools/

Last updated