19 | sudo command

Linux Command Line Tutorial


  1. In this tutorial, we will learn how to use sudo command.
  2. The sudo command allows you to run programs as another user, by default the root user.
  3. Sudo is one of the commands you use very often if you spend a lot of time on the command line.
  4. Using sudo as root instead of login is better since you can give individual users restricted administrative rights without knowing the root password.


18 | octal(777) chmod

Linux Command Line Tutorial


Everything is similar to the previous two videos in the series. The only difference is in this video we will learn how to use chmod with octal numbers.

In Octal

  • r = 4
  • w = 2
  • e = 1

This tutorial covers how to use the chmod command to change the access permission of files and directories.

In Linux, the file is associated with an owner and a group and assigned with permission access rights for three different classes of users:

  • The file owner
  • The group members
  • Others(everybody else)

File permissions can be changed. In order to do that we make use of chmod command.

There are three file permissions that apply to each class:

  • The read permission
  • The write permission
  • The execute permission
-rw-r--r-- 12 yash staff 128 Oct 2 12:31 myfile.txt
|[-][-][-]- [------] [---]
| | | | | | |
| | | | | | +-----------> 7. Group
| | | | | +-------------------> 6. Owner
| | | | +--------------------------> 5. Alternate Access Method
| | | +----------------------------> 4. Others Permissions
| | +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type


17 | directory and chmod

Linux Command Line Tutorial



Everything is similar to the previous video the only difference is we will see the behavior of directories and its contents when changing their permissions.

This tutorial covers how to use the chmod command to change the access permission of files and directories.

In Linux, the file is associated with an owner and a group and assigned with permission access rights for three different classes of users:

  • The file owner
  • The group members
  • Others(everybody else)

File permissions can be changed. In order to do that we make use of chmod command.

There are three file permissions that apply to each class:

  • The read permission
  • The write permission
  • The execute permission
-rw-r--r-- 12 yash staff 128 Oct 2 12:31 myfile.txt
|[-][-][-]- [------] [---]
| | | | | | |
| | | | | | +-----------> 7. Group
| | | | | +-------------------> 6. Owner
| | | | +--------------------------> 5. Alternate Access Method
| | | +----------------------------> 4. Others Permissions
| | +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type


16 | file and chmod

Linux Command Line Tutorial



This tutorial covers how to use the chmod command to change the access permission of files and directories.

In Linux, the file is associated with an owner and a group and assigned with permission access rights for three different classes of users:

  • The file owner
  • The group members
  • Others(everybody else)

File permissions can be changed. In order to do that we make use of chmod command.

There are three file permissions that apply to each class:

  • The read permission
  • The write permission
  • The execute permission
-rw-r--r-- 12 yash staff 128 Oct 2 12:31 myfile.txt
|[-][-][-]- [------] [---]
| | | | | | |
| | | | | | +-----------> 7. Group
| | | | | +-------------------> 6. Owner
| | | | +--------------------------> 5. Alternate Access Method
| | | +----------------------------> 4. Others Permissions
| | +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type


15 | echo command

Linux Command Line Tutorial


ANSI Escape Code
https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

In this video, we will learn how to use the echo command. The arguments passed to echo are printed to the standard output.

Echo is commonly used in shell scripts to display a message or output the results of other commands.

Although it is not necessary to enclose arguments in double-quotes it is good practice to do so.

If using ” each character enclosed within is preserved. Variable and commands will not be expanded.

Echo can be used with pattern matching characters, such as the wildcard characters.

echo "My txt files are: *txt"

Creating a variable in the shell for the current session. Don’t leave any space between equal sign.

myString="Hello World"
x=10

Display variable:

echo $myString
echo "x"

Echo can redirect commands output.

echo "Directory contents: $(ls -l)"


Options

CommandEffect
^OSave changes
^XExit nano
Save and Exit commands

14 | nano editor

Linux Command Line Tutorial


When working on the command line, quite often you will need to create or edit files. Two of the most famous and powerful command-line editors are Vim and emacs. On the other hand, they are equally difficult to learn. But there is a simpler editor available to just get things done and that is nano.

All commands are prefixed with a control(^) character or metacharacter(M). caret symbol represents control and M represents Meta. Control will generally be your control key. Meta character depends on the keyboard setup. It can either be an Esc key, alt key, or a special meta key.

In this video, I will help you learn the basic usage of the nano editor, including how to create an open file, edit a file, save a file, search and replace text, cut and paste text, and more.

If you wish to get more help, while inside nano editor hit: ^G


Navigation

CommandEffect
^FForward one character
^BBack one character
^SpaceForward one word
M-SpaceBack one word
^PPrevious line
^NNext line
^ABeginning of the current line
^EEnd of the current line
M-(Beginning of the current paragraph
M-)End of the current paragraph
M-\The first line of the file
M-/The last line of the file
^_Move the cursor to a specific line
Navigation commands

Search and Replace

CommandEffect
^WSearch pattern
M-WMove to the next match
^\Search pattern and replace
Search and Replace commands

Copy, Cut and Paste

CommandEffect
M-ASelect text(set a selection mark)
^6Cancel the selection press
M-6Copy the selected text to the clipboard
^KCut the selected text
^UPaste the text at the cursor position
Copy, Cut and Paste commands

Save and Exit

CommandEffect
^OSave changes
^XExit nano
Save and Exit commands

13 | less command

Linux Command Line Tutorial


In this video, we will learn how to use less command. less is a command-line utility that displays the content of a file or a command output, one page at a time. The less command is mostly used for opening large files.

The general syntax for using less command is:

less [options] filename

It is also possible to use less with other commands output.

ls /etc | less

When opening a file that is too large to fit in one page, you will see the colon at the bottom of the screen. What makes less more appealing is its ease of file navigation.

Navigation Commands

CommandOutput
f or space barnext page
j, down key or enternext line
k or up keyprevious line
bprevious page
Gend of the file
gstart of the file
[n]Ggoes to nth line
/[pattern]top-down search
?[pattern]bottom-up search
nnext search result
Nprevious search result
Navigation commands

Options

OptionEffect
-Nshow line numbers
-Xpreserve screen content after exiting less
+Fwatch out for changes being made to the file
Options for less command

Thank you 🙂


12 | touch command

Linux Command Line Tutorial


In this video, we will learn how to use touch command. The main purpose of this command is to change file access and modification time but it can be used to create a new file. In simple terms, it is used to change the timestamp of a given file.

touch can create a new file too. I find it much simpler to create a new file using touch. It is possible to create a file with any file extension. Moreover, you can create multiple files with just one command.

Remember you can always type man touch to learn more about the command.

We will also learn about some flags along with touch command:

-t = pass in custom timestamp
-a = just change access timestamp
-m = just change the modified timestamp
-r = copy timestamp from another file

Thank You!

11 | stat command

Linux Command Line Tutorial


In this video we will learn how to use stat command. stat is a command-line utility that displays detailed information about given files or file system. In simple words stat is used to display file information or properties.

Remeber you can always type man stat to learn more about the command.

We will also learn about some flags along with stat command:

-f = this flag is used for formatting custom output

Thank you 🙂

https://youtu.be/AAGOplby0dw

10 | alias | unalias

Linux Command Line Tutorial


In this video we will learn how to use alias and unalias command. alias are like custom shortcuts used to represent a command executed with or without custom options. You can save yourself some time by creating aliases for your most used commands.

Whereas unalias is used to remove the shortcut which was initially created. Pretty simle!

Thank you 🙂