Absolute Path
An "absolute path" on a Linux computer is like a full address for a specific file or folder. Just like how you need a full address to know where to send a letter, a computer needs a full address to know where to find a file or folder. An absolute path starts with the "root" folder, which is the very topmost folder on the computer, and then gives the complete list of all the other folders you need to go through to get to the file or folder you want.
To navigate to the topmost directory in linux type use the command “cd /”
Relative Path
A "relative path" on a Linux computer is like giving directions to a friend to find a toy at your house. Instead of giving the full address of your house, you can just tell them where to find the toy by saying things like "go in the front door, then go up the stairs, then turn left, then go into my room and it's on the shelf." A relative path on a computer works the same way. It tells the computer where to find a file or folder by giving directions starting from where you are right now in the file system, instead of starting from the very top. It makes it easier for you to navigate around the computer, because you don't have to remember the full address for everything.
To find what directory you are currently in use the command “pwd”
man Command
The "man" command in Linux is short for "manual." It is a command that you can use to read the manual pages for different programs and tools on your Linux computer. Manual pages are like instructions or a user guide for a program, that tells you what the program does, how to use it, and what the different options and commands are. When you type "man" followed by the name of a program, the manual page for that program will be displayed on the screen for you to read.
To find all of the different options for ls command use the command “man ls”
cd Command
The "cd" command in Linux is used to change the current directory. The "current directory" is like the folder that you are currently inside of on your computer. When you open a terminal window, you are automatically in a specific folder, and you can use the "cd" command to move around to different folders on your computer.
To find current directory start with the command “pwd”
To move to the upmost directory in linux type the command “cd /”
To move to the home directory of currently logged in user type the command “cd ~”
To move up one folder in the system type the command “cd ..”
To move to a folder using absolute path you must type in the full path of the desired location. For example to move into the home directory of the currently logged in user with absolute path type the command “cd /home/username”
To navigate to a directory from the current directory via relative path type the command “cd ‘directory-name’”
Relative path does not use the “/” in front of the path name. If you are moving to a directory that is held within another directory you will use the command “cd ‘directoryname1/directoryname2’”
ls Command
The "ls" command in Linux is used to list the files and folders in a directory. When you run the "ls" command, it will show you the names of all the files and folders that are inside the current directory.
To find all the options for the command use the command “man ls”
The most common options used with ls is l - long list format, t - newest first and r - reverse order while sorting and looks like this "ls -ltr"
wc Command
The "wc" command in Linux is short for "word count." It is a command that you can use to count the number of lines, words, and characters in a text file. In addition it will could the number of files in a directory using the pipe command.
To find all the options for wc use the command “man wc”
To display the amount of words in a text file use the command “wc -w filename”
To find the amount of files and directories in a directory you will need to use a pipe command. In this case is will look like this “ls | wc -l”
more and less Commands
The "more" command in Linux is used to display the contents of a text file one page at a time. When you run the "more" command followed by the name of a text file, it will show you the first page of the file, and then pause. You can then press the spacebar to see the next page, or press "q" to quit and exit.
The “less” command is just the more command in reverse but allows for you to go up and down with pgUP and pgDOWN buttons on the keyboard.
Change directory to the upmost directory with the command “cd /”
To view the contents of the directory page by page type the command “ls -ltr | more”
To view the contents of the directory in reverse order page by page with the ability to move up and down use the command “ls -ltr | less” to quit press q
grep Command
The "grep" command in Linux is used to search for a specific text pattern in a file or a group of files. "grep" stands for "global regular expression print." It searches for a specific string of characters, called a regular expression, within a file or a group of files and returns the lines that contain that expression.
To find a users details in the passwd file type the command “cat /etc/passwd | grep user”
To see what port the ssh service is running on you can use the command “sudo lsof -i -P -n | grep sshd”