WiFi Hotspot greyed – System Policy prohibits use as a Hotspot [Solved]

Sometimes when you open GNOME settings to the WiFi page, the “create hotspot” option is initially greyed out. This can be solved easily by switching to any other settings page and coming straight back makes the option available.

Steps to solve this

  1. Open GNOME Settings
  2. Try to activate hotspot, it is greyed out
  3. Switch back to “Network” or “Bluetooth” or any setting page and go back to WiFi settings
  4. Activate hotpot” menu option should be available now

This works in all Linux distros that use GNOME (Ubuntu, Manjaro, Fedora, etc..,)

Linux Beginner’s Guide Part 6

The ifconfig command is used to view the current network configuration for ethernet cards and iwconfig displays the network configuration for wireless cards.

ifconfig [OPTIONS]

iwconfig [OPTIONS]

[[email protected] ~]$ ifconfig
enp2s0f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether d8:c4:97:41:27:de  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 38  bytes 4503 (4.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38  bytes 4503 (4.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:55:6e:ed  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.182  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 2409:4072:610a:f3b:cb9c:bd9f:ff6e:a23c  prefixlen 64  scopeid 0x0
        inet6 fe80::9a9d:5958:dbf1:6836  prefixlen 64  scopeid 0x20
        ether 98:22:ef:b4:70:e7  txqueuelen 1000  (Ethernet)
        RX packets 265050  bytes 335273482 (319.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 109678  bytes 16079690 (15.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[[email protected] ~]$

The ifconfig and iwconfig can be used to make temporary changes in the network interfaces.

Processes

Running any kind of application/command/game and so on, creates something that is called process. The process runs with the privileges with the user who created it, this way the process is controlled and limited to run only under certain capabilities. The user who creates a process is the owner if it and it can not be controlled by other users with same or lower privileges. In our case, if the sysadmin user runs a process, another user with same or lower privilege level, can not control it but it can be controlled by the root user. The ps command is used to view the processes.

ps [OPTIONS]

The default output for ps command includes 4 columns and displays only the processes for the current terminal:

PID: process identifier, is a unique ID used to identify each process and to control it;

TTY: terminal name where the process is running, is used to identify a process if there are more that have same name;

TIME: total amount of processor time used by the process;

CMD: command that started the process;

To view the processes from the entire system ps -e command must be executed and ps -f displays more details for each process. The two commands above can be combined into one: ps -ef.

Updating the passwords in Linux

The passwd command is used to change the password. The users can only change their own password and the root user can change the password of any user.

passwd [OPTIONS] [USER]

If the passwd command is used without arguments, the terminal automatically starts the procedure for changing the password for current user.

If you want to see the details about the status of the password you must follow the following steps:

[[email protected] ~]$ sudo -i
[sudo] password for sulthan: 
[[email protected] ~]# passwd -S sulthan
sulthan PS 2020-08-08 0 99999 7 -1 (Password set, SHA512 crypt.)
[[email protected] ~]#

1st column: username – sulthan

2nd column: password statusP = usable password; L = locked password; NP = no password;

3rd column: date – when the password was last change

4th column: minimum – the minimum number of days until the user can change the password

5th column: maximum – the maximum number of days until the password will expire

6th column: warn – the number of days before the password will expire and the user will be warned

7th column: inactive – the number of days after the password will expire and the user will remain active

8th column: info – details about the password status and encryption

Linux Beginner’s Guide Part 5

Installing Packages / Applications / Software in Linux

The dnf in fedora (apt-get or apt in Ubuntu/Debian based distributions) command is used to install new packages and to update/upgrade the operating system, it requires administrative access, so it must be used with sudo.

dnf [OPTIONS] [COMMAND]
apt-get [OPTIONS] [COMMAND] (Ubuntu)
apt [OPTIONS] [COMMAND] (Ubuntu)

The operating system must be updated on a regular basis, this way you will keep your data and integrity of the system safe. In order to update your system, run one of the following commands:

dnf update
apt-get update

dnf upgrade (updates the obsolete packages too)
apt-get upgrade

After the system is updated you can run dnf clean, to erase the files that were left after the packages installed.

apt-get autoremove (Ubuntu)
apt-get autoclean (Ubuntu)
apt-get clean (Ubuntu)

To search for a specific package/application/software in the repository (we will search for Gimp – a graphic software) use:

dnf search gimp (apt-get search gimp in Ubuntu)

and to install it run:

dnf install gimp (apt-get install gimp in Ubuntu).

And if you no longer need it:

dnf erase gimp (apt-get remove gimp in Ubuntu).

(use: dnf reinstall gimp in case you deleted it by mistake)

By default the Linux repository contains only packages that are considered stable, but we will see later in this tutorial, how to modify the repository and add more packages.

Shutdown command in Linux

The shutdown command is used to prepare the system to turn off in a safe way, all logged in users will be announced that the system will be turned off and in the last 5 minutes new logins are blocked.

shutdown [OPTIONS] [TIME] [MESSAGE]

Please note that the shutdown command requires administrative access, so you must login with the root user: su root

The argument [TIME] can accept the following options: now, hh:mm, +minutes

To see the current date/time and date/time format of your system run this command in the console: date

Do a few exercises

shudown 08:32

shutdown +3 “Bye Bye!”

To stop a shutdown command you must use: shutdown -c

Su users can also use this command in order to issue a restart:

reboot

shutdown -r now

halt

Make sure you save your work before you run commands like restart or shutdown.

Linux Beginner’s Guide Part 4

Filtering Input

grep command is a text filter that searches for the input and returns the text lines by a given pattern.

grep [OPTIONS] [PATTERN] [FILE]

In order to start the example, use the following command to get to the /Documents/ folder: cd ~/Documents

and then copy the file on which we will make tests, to the current directory: cp /etc/passwd . (note the dot, it’s important!)

next, run the grep command line this:

grep sysadmin passwd

The line that will be returned from the passwd file contains the pattern sysadmin.

Edit passwd file, add more lines that will contain the word sysadmin, then run the grep command and see what happens.

Regular Expressions

Regular expressions have two forms: basic and extended,

Basic regular expressions:

. any one single character

[ ] any one specified character

[^ ] not the specified character

* zero or more of the previous character

^ if the first character in a pattern, the pattern must be at the beginning of the line to match

$ if the last character in a pattern, the pattern must be at the end of the line to match

Extended regular expressions (must be used with grep command or grep -E command):

+ one or more of the previous pattern

? the preceding pattern is optional

{ } specify minimum, maximum or exact matches of a previous pattern

| alteration, a logical “or”

( ) used to create groups

Basic patterns

Regular expressions can be improved in order to match certain sequences of characters in a text.

Anchor characters

Anchor characters are used to mark and filter search result. To prevent the shell from wrong interpretation of the commands the word to be searched for must be placed between ‘ ‘, like in the example below:

grep ‘root’ passwd

How many times the root word is displayed in the output? Correct answer is 4 times.

Run the following command: grep ‘^root’ passwd ( ^ character ensures that the pattern appears at the beginning of each line)

In the next example run cat command to see the contents of passwd file: cat passwd

Run: grep ‘n$’ passwd command and see what will be displayed. $ character ensures that the patterns appears at end of each line.

For example you can run: grep ‘n…..n’ passwd. It will mark all words that starts with n character have any 5 letters inside and ends with n character. You can also try: grep ‘…’ passwd or grep ‘.a..’ passwd and see what will be displayed.

Let’s try to filter numbers: grep ‘[0-9]’ passwd. This command will mark all numbers from 0 to 9.

To negate all numbers from 0 to 9 use the following command: grep ‘[^0-9]’ passwd

Mark special characters: grep ‘[.]’ passwd

To mark 0(zero) or more occurrences of a character: grep ‘s*’ passwd

grep ‘n[bs]s*’ passwd

As we will see later in this tutorial, grep is a very important command and will ease your work a lot if used properly.

Using grep with firewall logs: grep -iE ‘(192.168.1.1|DROP|DPT=443|)’ firewall.log
This command will search in firewall.log and will mark the ip 192.168.1.1 or DROP or DPT=443 (destination port 443, port 443 is used by https).

tail or cat commands can be combined with grep or egrep. This way will be outputted only the lines with the requested keywords:

cat | grep -iE ‘(192.168.1.1|DROP|DPT=443|)’ firewall.log

tail | grep -iE ‘(192.168.1.1|DROP|DPT=443|)’ firewall.log

On other Linux distributions might work as well the following commands, for multiple grep commands combined with cat, tac or tail:

cat firewall.log | egrep -iE “192.168.1.1|DROP|DPT=443”

tac firewall.log | egrep -iE “192.168.1.1|DROP|DPT=443”

tail firewall.log | egrep -iE “192.168.1.1|DROP|DPT=443”

Linux Beginner’s Guide Part 3

Working With Files

Creating Files

The touch command is used to create files of any type, for example, you can create test.txt, test.jpg, test.doc but only specialized software can read and create content in these file types.

touch [OPTIONS] FILE

go to Documents directory: cd ~/Documents/

and create a few test files: touch test1.sh test2.sh test3.sh test4.sh

view the files created: ls

As you can see touch command can be used to create multiple files at once.

Editors like vi, vim and nano can be also used to create files, but we will learn later in this tutorial about them.

Creating Folders

The mkdir command can be used to create folders. The basic structure is:

mkdir [OPTIONS] folder

Let’s create a few folders in /Documents/ directory:

cd ~/Documents/

mkdir example example1 example2

ls

One nice feature of mkdir command is that you can create full paths using argument -p:

mkdir -p example3/example/inside/example

ls

cd example3

ls

cd example

Moving Files

The mv command is used to move a file from a place to another one. The mv command can have two arguments: source and destination. The source is the place where the file is located and the destination is the place where the file should be moved.

mv [SOURCE] [DESTINATION]

Switch to the Documents directory:

cd ~/Documents

Move test.sh file into Work directory, the file is the [SOURCE] and the directory is the [DESTINATION]:

mv test.sh Work

ls Work

mv command can be used also to move and in the same time rename the file.

mv test.sh Work test1.sh

ls

The mv command can be used to rename a file in the same directory:

mv test.sh test1.sh

With mv command multiple files can be moved at the same time.

mv test2.sh test3.sh test4.sh Work

ls

Copying Files

Making copies of a file is very useful and they can be created as a backup, as a template or can be transferred to different media types.

cp [OPTIONS] [SOURCE] [DESTINATION]

Use the command below to get to the Documents directory:

cd ~/Documents

The cp command is used to copy files and is similar to mv command, it requires at least these two arguments: [SOURCE] [DESTINATION]

Let’s say we have to copy /etc/passwd to the current directory:

cp /etc/passwd .

The second argument is the . (dot) which represents the current directory, acts like a shortcut.

Please note that permissions have impact on commands like cp, it is necessary to have execute permissions to access the directory and read permissions on the file being copied and also you must have write and execute permissions on the directory where the file will be copied.

dd command is a utility that copies files or entire partitions at a bit level.

dd [OPTIONS] [OPERAND]

dd command is very useful for:

  • deleting or cloning entire disks or partitions
  • copying raw data to external devices like memory sticks, CDs, DVDs, and so on
  • backup and restoring of Master boot record (MBR)
  • creating a file with a specific size filled with zeros, which can be used as swap file (virtual memory)

Let’s create, with the dd command, a file named /tmp/buffer with 100 blocks of zeros that are 1MB in size:

dd if=/dev/zero of=/tmp/buffer bs=1M count=100

Below you can find the description of a few arguments that dd uses:

if = input file = the input file to be read from

of = output file = the output file to be written

bs = block size (block size units: K, M, G, T)

count = the number of blocks to be read from the input file

To clone from hard drive to another bs or count must not be specified.

dd if=/dev/sda of=/dev/sdb

Removing Files

rm command is used to delete files and directories. Please keep in mind that if you delete the files they are not moved to “Trash”, they are removed permanently.

rm [OPTIONS] [FILE]

To remove a file use the following command: rm linux.txt

To remove a directory, use the following command: rm -r linux

Permissions have impact on commands like rm. To delete files within a directory, the user must have execute and write permissions on this directory.

Using help in Linux Terminal

Before you start this tutorial is better to know how to get help and details about the commands, when you need it. There are several ways to get help about the commands, but I will present only the most important ones:

Using –help as an argument for the command

Example: cp –help

Using man as a pre-argument for the command

Example: man cp

Using info as a pre-argument for the command

Example: info cp

[TAB] key from the keyboard can be used to autocomplete commands, arguments and known terms, by the console/terminal:

Example: dnf ins (press [TAB] key, it will autocomplete the argument install), the final command line will be: dnf install

Other useful commands in Linux terminal/console:

clear cleans the current terminal window

history shows last 500 commands used in the terminal, it can be limited with history 10 (shows last 10 commands used)

reset refreshes the terminal/console

exit exits the current terminal/console

Useful keyboard shortcuts in Linux terminal/console:

[Ctrl + l] clears the current terminal/console

[Ctrl + u] clears the current line from the cursor point

[Ctrl + a] move the cursor at the beginning of the line

[Ctrl + e] move the cursor at the end of the line

[Ctrl + d] exit current terminal

[Tab] autocomplete commands

[Up/Down arrow] show commands history

Linux Beginner’s Guide Part 2

Administrative Access

Many Linux commands deal with sensitive data like system hardware, passwords or operate under exceptional circumstances. Prevents regular users from executing these commands by mistakes and helps to protect data and system integrity. By logging in as root enables the ability to execute privileged commands.

sudo Command

The sudo command allows a user to execute a command as another user, but will not create a new shell. sudo assumes that the default root user should be used to run the command. If you want to run a command using sudo, but as another user, -u option should be used

[[email protected] ~]$ sudo -u sulthan ls -l
total 40
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Desktop
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 11:42  Documents
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 10:42  Downloads
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Music
drwxrwxrwx. 5 sulthan sulthan 4096 Aug  9 10:55 'OS and Softwares'
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Pictures
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Public
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Templates
drwxr-xr-x. 2 sulthan sulthan 4096 Aug  9 01:09  Videos
drwxr-xr-x. 3 sulthan sulthan 4096 Aug  9 11:04 'VirtualBox VMs'
[[email protected] ~]$ 

Example: sudo -u username

Permissions

Determines the ways that users can interact with files and directories. When executing the command ls -l, the output includes permission details.

File Type Field

The first character indicate the type of the file. If it’s a “ – ” character, this is a regular file. The “ d ” character is for the directories.

Permissions Field

The next 9 characters, after the file type character, indicates the permissions. These are broken in sets of 3 characters.

Owner

The first set of 3 characters is for the user who owns the file. If the current account is the user owner of the file then the first set of permissions will apply and the others will have no effect. To determine which of the users is the owner we can take a look at the user owner field.

Group

The second set of 3 characters if for the group that owns the file. If the current user is not the owner of the file and you are member of the group that owns the file, then this set of permissions apply and the others have no effect.

The group for this file can be identified if you take a look at the group owner field.

Other

The last set of permissions if for everyone else. If you are not the owner and you are not a member of the group, than the last set of permissions applies to you.

Permissions Types

r: contents of the file can be read or copied

w: contents of the file can be modified/deleted/overwritten. Allows the file to be added ore moved from a directory

x: a file can be executed/run as a process. Script files require read permissions as well.

Changing Permissions

The file permissions can be changed only by the root user or by the user that owns the file. The chmod (change the modes of access) command must be used in order to change the permissions of a file.

Using the chmod command there are two ways to change the permissions of the file: symbolic and octal.

Symbolic method is good to change a set of permissions at a time.

Octal/numeric method requires knowledge of the octal values of each permission and also requires all 3 sets of permissions, user, group, other to be specified each time.

Linux Beginner’s Guide Part 1

Linux is Everywhere!

(I won’t bother you too much with this introduction because I know how excited I was when I started for the first time to learn Linux. You can find here a small Linux Introduction.)

Linux is a very flexible operating system and as you already may know it can be found in everything from automobiles to rockets, phones, servers, personal computers, watches, TVs, IoE/IoT devices and the list continues…

I hope that you will find this tutorial very interesting and you will enjoy it!

What do I need in order to learn Linux?

  1. PC/Notebook (depending on Linux version that you would like to use I recommend: RAM – Min 4GB, CPU – Dual/Quad Core)
  2. Virtualization Software: Oracle VirtualBox (recommended and also free software) / VMWare (paid software)
  3. Ubuntu image file

Note: I do not recommend to install Linux (at this moment) as a SecondBoot or as a default operating system of your PC/notebook. What I recommend is to install Ubuntu on a Virtual Machine.

Basic Linux Commands and Syntax

This tutorial deals exclusively with the CLI (Command Line Interface). The CLI is a very powerful interface that allows the users to administer small devices, extremely capable cloud computer servers, network devices and everything between them.

A command is a software program and when executed on the CLI, performs an action on the computer. First of all install Ubuntu on the VirtualMachine Software, power on Ubuntu machine, login on the system and open the terminal window.

To execute a command, first type the command, for example ls, and hit Enter.

[email protected]:~$ ls
Downloads                  Pictures          snap             Public            Templates                  Desktop           Videos           Documents                 Music

Note: The commands are case sensitive, so LS will not execute but ls will execute.

[email protected]:~$ LS
LS: command not found

Most of the commands follow a simple syntax:command [options] [arguments]. You have to type the command followed by options and/or arguments and then press Enter. The options usually alter the behaviour of commands and arguments.

Arguments

An argument can be used to specify something that the command should act on. For example, you can try the following example:

Example: ls /var/log (ls = “list” lists the contents of directory /var/log)
In this example /var/log/ is the argument used with ls command.

[email protected]:~$ ls /var/log
alternatives.log  dist-upgrade    gdm3             openvpn
apt               dmesg           gpu-manager.log  private
auth.log          dmesg.0         hp               speech-dispatcher
boot.log          dmesg.1.gz      installer        syslog
bootstrap.log     dpkg.log        journal          ubuntu-advantage.log
btmp              faillog         kern.log         unattended-upgrades
cups              fontconfig.log  lastlog          wtmp

Options

Options are used to alter the behaviour of commands. In the next example, we will use -l option with ls command and see what happens.

Example: ls -l (-l = “long display”, means that will give more information). It will output detailed information about the listed files.

[email protected]:~$ ls -l
total 34
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Desktop
drwxr-xr-x  5 sulthan sulthan  4096 Aug  8 00:27  Documents
drwxr-xr-x  3 sulthan sulthan  4096 Aug  8 19:00  Downloads
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Music
drwxr-xr-x  7 sulthan sulthan  4096 Aug  8 02:47  Pictures
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Public
drwxr-xr-x  3 sulthan sulthan  4096 Aug  7 22:16  snap
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Templates
drwxr-xr-x  8 sulthan sulthan  4096 Aug  7 23:46  Videos

Example: ls -r (-r “reverse”, it will reverse the alphabetical order)

[email protected]:~$ ls -r
 Music             Documents         Videos            Desktop
 Templates        Public             snap              Pictures           Downloads

Options can be used at once, combined or separated, but the output will be the same. Order of the options does not matter.

Example: ls -r -l (separated)

[email protected]:~$ ls -r -l
total 34
drwxr-xr-x  8 sulthan sulthan  4096 Aug  7 23:46  Videos
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Templates
drwxr-xr-x  3 sulthan sulthan  4096 Aug  7 22:16  snap
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Public
drwxr-xr-x  7 sulthan sulthan  4096 Aug  8 02:47  Pictures
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Music
drwxr-xr-x  3 sulthan sulthan  4096 Aug  8 19:00  Downloads
drwxr-xr-x  5 sulthan sulthan  4096 Aug  8 00:27  Documents
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Desktop

Example: ls -lr (combined)

[email protected]:~$ ls lr
total 34
drwxr-xr-x  8 sulthan sulthan  4096 Aug  7 23:46  Videos
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Templates
drwxr-xr-x  3 sulthan sulthan  4096 Aug  7 22:16  snap
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Public
drwxr-xr-x  7 sulthan sulthan  4096 Aug  8 02:47  Pictures
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Music
drwxr-xr-x  3 sulthan sulthan  4096 Aug  8 19:00  Downloads
drwxr-xr-x  5 sulthan sulthan  4096 Aug  8 00:27  Documents
drwxr-xr-x  2 sulthan sulthan  4096 Aug  7 21:53  Desktop

Printing Working Directory

To discover where we are located within file-system, we can use pwd command. We will use the term “Print” not to send information to a physical printer, but to send the information to be printed to the screen.

pwd [options]

[email protected]:~$ pwd
/home/sulthan

Changing Directories

Directories are type of file used to store other files, they also provide hierarchical organization structure. To navigate the filesystem you can use the command cd (Change Directory).

cd [options] [path]

[email protected]:~$ cd Desktop
[email protected]:~/Desktop$

Listing files

The ls command is used to list the contents of a directory.

ls [options][path]

To get more details about a file, like permissions, ownerships or timestamps, perform a longlisting using -l option with the ls command.

Example: ls -l /var/log

[email protected]:~$ ls -l /var/log
total 5376
-rw-r--r--  1 root              root              37174 Aug  8 02:33 alternatives.log
drwxr-xr-x  2 root              root               4096 Aug  8 12:40 apt
-rw-r-----  1 syslog            adm               45255 Aug  8 19:30 auth.log
-rw-------  1 root              root              24051 Aug  8 09:56 boot.log
-rw-r--r--  1 root              root             104003 Jul 31 21:57 bootstrap.log
-rw-rw----  1 root              utmp                  0 Jul 31 21:57 btmp
drwxr-xr-x  2 root              root               4096 Aug  7 21:52 cups
drwxr-xr-x  2 root              root               4096 Jul 21 05:53 dist-upgrade
-rw-r--r--  1 root              adm               78208 Aug  8 09:57 dmesg
-rw-r--r--  1 root              adm               79444 Aug  8 01:36 dmesg.0
-rw-r--r--  1 root              adm               19850 Aug  7 21:52 dmesg.1.gz
-rw-r--r--  1 root              root            1395217 Aug  8 12:40 dpkg.log
-rw-r--r--  1 root              root              32064 Aug  7 22:53 faillog
-rw-r--r--  1 root              root              11126 Aug  8 02:33 fontconfig.log
drwx--x--x  2 root              gdm                4096 Oct  7  2019 gdm3
-rw-r--r--  1 root              root               1242 Aug  8 09:56 gpu-manager.log
drwxr-xr-x  3 root              root               4096 Jul 31 21:59 hp
drwxr-xr-x  2 root              root               4096 Aug  7 21:50 installer
drwxr-sr-x+ 3 root              systemd-journal    4096 Aug  7 21:51 journal
-rw-r-----  1 syslog            adm              767403 Aug  8 19:19 kern.log
-rw-rw-r--  1 root              utmp             292584 Aug  7 22:53 lastlog
drwxr-xr-x  2 root              root               4096 Sep  5  2019 openvpn
drwx------  2 root              root               4096 Jul 31 21:57 private
drwx------  2 speech-dispatcher root               4096 Jan 19  2020 speech-dispatcher
-rw-r-----  1 syslog            adm             2799670 Aug  8 19:42 syslog
-rw-------  1 root              root                  0 Jul 31 21:57 ubuntu-advantage.log
drwxr-x---  2 root              adm                4096 Aug  7 21:52 unattended-upgrades
-rw-rw-r--  1 root              utmp               4992 Aug  8 10:10 wtmp

Each line contains the details about every file in the directory. The details are broken into columns separated by spaces.

File Types

The first column contains ten characters, the first character indicates the type of the file and the next nine characters indicates the file permissions:

d | directory | A file that contains other files
| regular file | Readable, images, binary and compressed files
l | symbolic link | Points to other files
s | socket | Allows for the communication between processes
p | pipe | Allows for communication between processes
b | block file | Used to communicate with hardware
c | character file | Used to communicate with hardware

Permissions
Permissions indicate how users can access the files.

Hard Link Count

This number indicates how many hard links point to the file.

User Owner

When a file is created the ownership is automatically assigned to the user who created it.

Group Owner

Shows which group owns the file.

File Size

In case of a file, the size is displayed in bytes and in case of a directory, multiple of the block size used by the file system.

Timestamp

Indicates the time when the file’s content was last modified.

Filename

The last field contains the name of the file or directory.

Symbolic Links

Symbolic link name will be displayed along with an arrow and the link to the original file.

Sorting

The output of the ls command is sorted alphabetically by filename, but it can be modified by ls options. In the example below ls command will be combined with -l option so the relevant details to be displayed and with the -S option which sorts by size.

The -S option will sort the files by size.

The -r option will reverse the order of any type of sort.

 

List of useful GIT Commands in Linux

Installation

sudo apt install git – installs GIT from repositories

Configuration

git config –global user.name “Your Name” – the name that will be added to commits and tags
git config –global user.email “[email protected]” – the e-mail address that will be added to commits and tags
git config –global color.ui auto – enables the colors in GIT output

Also read: How to use GIT in Linux

Starting

git init [project name] – creates a new local repository
git clone [project url] – gets a project from remote repository

Common

git status – shows the status of your work
git diff – shows the changes
git checkout – discards changes in working directory
git add – adds a file to staging area
git reset [file] – gets file back from staging area
git commit [-m “message”] – commits the changes added to staging area
git rm [file] – removed the file from working directory and adds deletion to staging area
git stash – puts changes into stash
git stash pop – applies the changes in the stash and clears its contents
git stash drop – clears the stash contents

Branching

git branch [-a] – lists all branches in repository
git branch [name] – creates a new branch
git checkout [-b] [name] – changes working directory to the mentioned one
git merge [from name] – Combines the specified branch with the current one
git branch -d [name] – removes branch

Tags

git tag – lists tags
git tag [name] [commit *] – creates a tag for current commit
git tag -a [name] [commit *] – creates a tag object for current commit
git tag -d [name] – removes a tag from repository

Review

git log [-n count] – lists commit history
git log –oneline –graph –decorate – shows references and history graph
git log ref.. – shows commits that are present on current branch and not merged into ref
git log ..ref – lists commits that are present on ref and not merged into current branch
git reflog – list operations made on local repository

Sync

git fetch [remote] – gets changes from the remote but does not update the branches
git fetch –prune [remote] – removes refs from remote
git pull [remote] – gets changes from the remote and combines current branch with it
git push [–tags] [remote] – pushes local changes to remote
git push -u [remote] [branch] – pushes local branch to remote repository

Reverting

git reset [–hard] [target reference] – switches current branch to the target reference
git revert [commit *] – createa a new commit, reverting changes from the specified commit

Ignoring

cat .gitignore
#Contents of .gitignore
/logs/*
!logs/.gitkeep
/tmp
*.swp

Using GIT in Linux

How to use GIT in Linux

GIT is a revision control system that allows multiple contributors to work on the same projects/files. Is also useful if you have more servers/VMS/workstation that you manage and you want to deploy “recipes”/scripts/configurations on them. With GIT, you work locally, push the changes to the repository server and then get your files from any location you want. GIT tracks the changes made to the files and if a config is not working it can be reverted in no time.

To start learning GIT, I recommend using GitLab, is free, very versatile and your repository will be in private mode. You can also try GitHub, the free version is in public mode (Do not store passwords or sensitive information in your files, if you use repositories that are in public mode).

Also read: List of useful GIT Commands in Linux

Preparing GIT environment

Open Linux Terminal in ROOT mode

sudo bash

Install GIT

Fedora/CentOS/Red Hat

dnf install git

Debian/Mint/Ubuntu

apt-get install git

Install xclip (useful to copy file contents to clipboard)

Fedora/CentOS/Red Hat

dnf install xclip

Debian/Mint/Ubuntu

apt-get install xclip

Create and activate an account on GitLab

Add GIT username

git config –global user.name “USERNAME”

git config –global user.name (verify your username)

Add GIT e-mail address

git config –global user.email “[email protected]”

git config –global user.email (verify e-mail address)

git config –global –list (verify username and e-mail)

Check if your system has an SSH Key so you can link it with your GitLab account

cat ~/.ssh/id_rsa.pub (if it’s displayed something starting with ssh-rsa, you don’t have to follow the next steps about key creation)

Creating SSH key

ssh-keygen -t rsa -C “[email protected]” -b 4096

Changing SSH key (optional)

ssh-keygen -p <keyname>

Copy key to clipboard with xclip

xclip -sel clip < ~/.ssh/id_rsa.pub

Go to your Profile settings in GitLab -> SSH Keys and paste the contents of the clipboard.

Do a checkout on your master branch

git checkout master

Download the latest changes

git pull REMOTE NAME-OF-BRANCH -u

Create a new branch

git checkout -b NAME-OF-BRANCH

Work on the branch

git checkout NAME-OF-BRANCH

View the changes that you have made

git status

Commit your changes

git add file_name.extension

git commit -m “short description”

Send changes to your gitlab.com

git push REMOTE NAME-OF-BRANCH

After you have made all the above changes, you can use short commands, git pull to get the latest updates and git push to upload the current modifications.