Linux Basics - Introduction to the Linux Command Line
This post is an accompaniment to my YouTube series video - Intro to Linux CLI providing all the commands we looked at. If you're viewing this blog and have not seen the video, then take a look as we go through live demos of all the commands here.
The command line is the most powerful place in Linux and Windows. In Linux we use the Terminal to access the CLI.
The Linux CLI is case sensitive so attention to detail when entering commands is vital!
You use the CLI by providing commands and arguments - every action in a GUI is actually a bunch of commands and arguments in the background.
In the CLI:
$ prompt = standard user
“#” prompt = root/super user
Sudo - What is it and what does it mean. Sudo is the Linux equivalent of the Windows Administrator. It stands for Super User DO. It elevates the privileges of your standard account to administrator level (Super User) to perform certain tasks.
whoami
= shows the current user
hostname
= shows the name of the host machine
pwd
= shows the current working directory - essential for knowing where in the file system you are
To update your system:
sudo apt update && sudo apt upgrade -y
- "sudo" is us asking the system to elevate our privileges to carry out the following command. "apt" is the command that we will carry out, which is the package manager for the likes of Kali and Ubuntu. "update" is the argument, what we want the command to do (to update the repositories). The double 'and' sign "&&" is chaining two commands together. Next we elevate our privileges again, run the "apt" command but this time pass the "upgrade" argument to tell the system to install the updates. Finally, we pass this command another argument of "-y" to tell the system to not prompt us before installing.
This can take anywhere from a few seconds to 15 minutes, depending on how recently the system was last upgraded!
clear
or <ctrl>l = clear the screen
<ctrl>c = will break the running command
<ctrl><shift>c = copy
<ctrl><shift>v = paste
<ctrl>left arrow = move to the start of word to the left of the cursor
<ctrl>right arrow = move to the end of the word to the right of the cursor
arrow up = scroll up through command history
arrow down = scroll down through command history
history
= shows all command history
!n = use the line n in the command history list (after showing the history list)
history -c
= clear the command history
When starting out, use the GUI to help find your way around!
ls
= shows a list of the files and directories contained in the current directory (contents of the current working directory)
ls -lah
= is useful as it shows the long format, all files and folders (even hidden ones) and human-readable.
cd ..
= (change directory) navigates backwards one directory - the prompt will change to reflect the new working directory
cd ../..
= will go back 2 directories
cd {directory name}
= navigates into the specified directory - the prompt will change to reflect the new working directory
man {command}
= shows the manual page for the specified command - useful when you need to know what the command does and the arguments it supports etc. Press q to exit the manual page.
{command} --help
= (command then 2 dashes then help) will show brief info about the command and it’s usage options.
https://explainshell.com/ = for more help on commands.
In the next Blog and Video, we'll be looking at Files and Directories on the Command Line.
Thanks for reading.
Rich.
No comments:
Post a Comment