The command will return an absolute (full) path, which is basically a path of all the directories that starts with a forward slash (/).
An example of an absolute path is /home/username
🔸cd -
To change to a different directory
Example: cd workspace
There are some shortcuts to help you navigate quickly:
-> cd .. to move one directory up
-> cd to go straight to the home folder
-> cd- to move to your previous directory
🔸ls -
To list the contents of a directory
Variations with the ls command:
-> ls -R will list all the files in the sub-directories too
-> ls -a will show the hidden files
-> ls -al will list the files and directories with detailed information like the permissions,size,owner,etc
🔸mkdir -
To make a new directory
Example: mkdir abc
-> To generate a new directory inside another directory, use this command mkdir abc/def
🔸rmdir -
To remove an empty directory
Example: rmdir abc
Note if the directory contains files or subdirectories, it does not remove the directory.
🔸touch -
To add files
Example: touch abc/pqr.txt
This creates a new txt file named pqr inside abc
🔸cat -
To print out contents of a file
Example: cat abc/pqr.txt
Other ways to use the cat command:
-> cat > filename creates a new file
-> cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
🔸tree -
To print out the layout of files and directories under it in a tree fashion
🔸cp -
To copy the file from the current directory to a different directory
Example: cp pqr.txt /home/username/MyFiles
It would create a copy of pqr.txt from your current directory into the MyFiles directory
🔸rm -
To remove a file
Example: rm abc/pqr.txt
It would remove the pqr.txt file
🔸mv -
To move files, can also be used to rename files. Arguments are similar as in the cp command
To rename files, the Linux command is:
mv oldname.ext newname.ext
🔸echo -
To move some data into a file
Example: echo Hello world >> pqr.txt
It will add the text "Hello world" into the file pqr.txt
🔸ping -
To check connectivity status to a server
Example: ping google.com
It will check whether you’re able to connect to Google and also measure the response time
🔸grep -
It lets you filter/search through all the text in a given file
Its usage is: grep <pattern> <file>
🔸head -
To view some lines of a file from start
Its different usages are :
-> head filename: To view first 10 lines of the file
-> head -n number filename: Number of lines required
-> head -c bytes filename: Number of bytes required
🔸IP address -
IP stands for Internet Protocol Address. It is a numerical label assigned to each device connected to a computer network that uses Internet Protocol for communication.
The internet needs a way to differentiate between different computers, routers, and websites. IP addresses provide a way of doing so and form an essential part of how the internet works.
🔸Repository
A repository is like a folder for your project. It contains the collection of the file as well as the history of the changes made to those files. Sometimes Github users shorten this as 'repo'
🔸Branch
A branch is a parallel version of a repository. It is contained within the repository but does not affect the primary or master branch allowing you to work freely without disrupting the 'live' version.
🔸JSON stands for JavaScript Object Notation.
🔸JSON is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute-value pairs and arrays.
🔸JSON is a language-independent data format. It was derived from Javascript, but many modern programming languages include code to generate and parse JSON-format data.