> For the complete documentation index, see [llms.txt](https://sec-nadesh.gitbook.io/security-fundamentals-commands/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sec-nadesh.gitbook.io/security-fundamentals-commands/basics-linux.md).

# Basics Linux

## Traverse

`pwd` → Print working directory

`cd` → Change directory (Ex: `cd /home/Nadesh/Documents` change to Documents directory)

`cd ..` → Change directory to parent directory

`cd ~` → Change directory to your home directory

`cd -` → Go back to previous directory

## Look

`ls` → List files in directory

`ls -la` → Shows a detailed list of files in long format (`-l`) and lists all hidden files (`-a`)

`file` → Shows info about a file (what type of file it is) and a description of the file's contents

`cat` → Output the content of a file

`less` → Output the content of a file in a page manner, so you can navigate through a text file page by page

`more` → Output the file but hust a little bit at a time, similar to `less`

## Frequently used

`history` → Show commands history

`sudo` → Used before commands to execute this commands as root

`sudo -l` → List what rights the sudo user has

`cat /etc/sudoers` → Find which users have sudo rights

## Locate files/ folders

`find` → Slower command to locate files but a lot more thorough. You can search for files recursively and with regex and lot of more features

`find /home -name Nadesh.jpg` → Find if there is a file named picture.jpg in the home directory

`find /home -type d -name MyFolder` → Find a directory (`-type d`) named `MyFolder` in the home directory

`find / -name file 2>/dev/null` → Send all permissions denied outputs to `dev/null`

`locate` → Locates files or directories really fast on an internal database

`sudo updatedb` → Updates database in order to run the `locate` command

`which` → Outputs the path of the binary that you are looking for, searching through the directories that are defined in you $PATH variable
