> The Command Line is a text based interface to the system where the user enters commands using the keyboard and will get a response based on that command.All terminals have
shells
but the most commonly used one isbash
which stands for Bourne again shell. runecho $SHELL
to see what your current shell is.
Navigation is an important part of using the command line. A lot of the things we do, such as cloning GitHub Repos or creating/delete files, depend on being able to point to the correct location of a file or director. Here are a few code commands commonly used.
pwd
- Print Working Directory - Outputs your currently location in the Terminal.ls
- List - lists out all the items in the current location. You can list out items in a different different directory without navigating to that specific directory by typing the path after ls
for example ls /anotherFolder
cd
- Change Directory - Moves you from one directory to another.
~
= shortcut to the home directory./
= refers to all things in the current directory../
referes to all things in the parent directory (Add on extra ../
to move up an additional level)In Linux, EVERYTHING is a file. If we want to know what type of file something is, we just need to type file [path name]
. For example, if I ran the file projects
on my projects folder, the terminal will output projects: directory
.
### Things to note
'\'
so that the CL can interpret where we want to go for example: File Name.txt = 'File Name.txt'
or File\ Name.txt
-a
after the list command eg ls -a
.Manual pages are a set of pages that document what a command is, it’s purpose, and its use. to look up a specific command you would type out 'man [comnmand to look up]'
for example 'man ls'
. Manual pages can also be searched using keywords 'man -k [search term]'
.
File manipulation covers all the things we can do in the file explorer but from the command line. these include Creating, deleting, renaming, and moving folders and files.
- mkdir <directory name> - Creates a directory
- rmdir <directory> - removes a directory
- cp <source> <destination> - copies a file (source) and creates a new file (destination)
- cp -r <source> <file> - Recursive copy that allows us to create copies of a directory.
- mv <source> <destination> - move items or directories into another directory. the `mv` command can also be used to rename files
- rm <file name> - deletes a file
- rm -r <directory> - removes a non-empty directory.