Author Archives: Hadi Yahya

Creating a Linux File with Touch

To create an empty file called testfile within your current directory, use the following command:

To edit this file, you must use a text editor.

You can create a file in a different location by changing what is after touch. To create a new file in /home/hadi/testdirectory, if you are already in your home directory, you can use the following:

Of from anywhere using an absolute path, you can use this:

Or from anywhere using a path shortcut, you can use the following command:

Navigating the Linux File System

Mastering navigating the Linux file system will fasten access specific file or folder. If the Linux OS come with GUI then you got no issue navigating using interface but if the Linux OS is minimal version then navigate using CLI is a must.

First you need to know directory parent and children. Example as below:

Type of DirectoryExample
Parent/home/hadiyahyalab
Children/home/hadiyahyalab/Downloads

Listing the Contents of a Directory with ls

The ls command lists the contents of the current directory.

Below show the lists content of home directory.

To show hidden files, use below command.

To include details such as the file/folder permissions, owner and group, size and the date and time, enter the following command:

Here the explanation of the listing newfile.txt

ParameterExplanation
Filetype“-“rw-r–r– (refer to files)

Additional info:
“d”rwxr-xr-x (refer to directory/folder)
Permissionsrw-r–r–
Link Count1
OwnerHadi
GroupHadi
Filesize6
Last access date/timeMac 26 09:54
Filenamenewfile.txt

Another useful command as below:

  • ls -R

As you can see the command scans and lists all the contents. The information can be lengthy but you can simplify by redirect the output to a text file. Example as below:

And here the output from the homedir.txt, I using command less for me go through page by page or line by line.

Changing Directories with cd

Use the cd command to move within the file system from one directory to another.

Example:

I do a ls command to show available directory. I want to change directory to Pictures, so I use command cd Pictures. You can see the change on my CLI view.

To move up to parent directory use the below command.

To return to home directory use the below command.

Another command below also help you to return to home directory.

Finding Your Current Directory with pwd

Use pwd to check the current directory you have access.

Basic Understanding the Linux File System Hierarchy

Linux file system is inherited from UNIX. Knowing there directories can help you find files when you need them. I also not remember all but it is to know some of it.

DirectoryDescription
/The root directory
/binEssential commands
/bootBoot loader files, Linux kernel
/devDevice files
/etcSystem configuration files
/homeUser home directories
/libShared libraries. kernel modules
/lost+foundRecovered files (if found after a file system check)
/mediaMount point for removable media, such as DVDs and floppy disks
/mntUsual mount point for local, remote file systems, file systems that are additional to the standard, such as a DVD-ROM or another HDD
/optAdd-on software packages
/procKernel information, process control
/rootSuper user (root) home
/sbinSystem commands (mostly root only)
/sysReal-time information on devices used by the kernel
/tmpTemporary files
/usrSoftware not essential for system operation, such as application
/varVariables files relating to services that run on the system, but whose contents are expected to change regularly during normal operation
Basic Linux Directories

To read the ma page for the Linux file system hierarchy. Use below command.

  • man hier

This returns a detailed listing, with a description of each part.

.::End of post::.

Using apt-get Instead of apt

In previous post I share about Day-to-Day APT Usage, the apt command is a new version of apt-get command. It provide simplified because of no hyphen and included with progress bar. Both command work as it is.

Today, apt-get is used much more advanced package management task.

apt-get Commandapt Command
apt-get installapt install
apt-get remove apt remove
apt-get update apt update
apt-get upgrade apt upgrade
apt-get dist-upgrade apt full-upgrade
apt-get remove –purge apt purge
apt-get autoremove apt autoremove
apt-get search apt search
apt-get show apt show
dpkg –get-selections apt list –installed
apt-get purge apt purge
Table apt-get Versus apt

.::End of post::.

Day-to-Day APT Usage

APT stand for Advanced Package Tool. APT also the first system to properly handle dependencies in software. If you want to install software like Libre Office, APT downloads Libre Office package and any other software it needs to work. APT also handles installation resuming if the internet connection is lose.

APT UPDATE & APT UPGRADE

APT uses a local cache of the available packages. Run the command below:

  • sudo apt update

As you can see APT will communicate with all the servers it is configured to use and download the latest list of file updates. If the list outdated, it will download the updates.

Next we can ask APT to automatically download any software that have been updated. Run the command below:

  • sudo apt upgrade

Below result the system already upgraded.

If the system is not upgrade, there will be a number of package that need to upgrade. It will show the download size of the package.

Remember, apt upgrade never removes software or adds new software!

If “0 not upgraded” status change, some things cannot be upgraded because of the update list didn’t satisfy the dependencies. In resolve this situation, we need to use apt dist-upgrade this allow to upgrade from one version of Debian/Ubuntu to a newer version.

APT INSTALL

This action is responsible for adding new software. For example, if I want to install MySQL database server. Here example command:

  • sudo apt install mysql-server

The output of the command tells:

  • All the dependencies required to install MySQL Server
  • There version that will install is MySQL-Server-8.0
  • There also suggested packages that can be install
  • Size the will be occupied on disk.

If the software/packages already installed, the apt install will be consider it as apt update and looks to see whether new versions are available for download.

APT REMOVE

The action is to remove the things that no longer want. The command as below:

  • sudo apt remove

Warning! Removing packages can be dangerous because APT also removes any software that relies on the packages that selected. Make sure to read the output carefully before proceed press Y to continue with the uninstall.

After the remove complete, the configuration files of the program is leave behind. If you reinstall, you don’t need to reconfigure it.

If want to remove the configuration file during the remove action, use below command:

  • sudo apt purge firefox

As you can see there is additional action perform by purge command. It will purging configuration files once the firefox is removed.

.::End of post::.

Ubuntu Reading Documentation

Like others operating system, Ubuntu also included the documentation with their system. This will help you to understanding the system and perform troubleshooting.

Using Man Pages

The man command followed by the name of command or program will show the manual pages. All the Man pages are stored in places like /usr/share/man and /usr/local/share/man, but to read a man page for ls command, use the man command as below:

Press enter and you will see the man page of ls command.

To scroll the page:

  • vertically – press arrow down/up
  • horizontally – press arrow right/left
  • next page – press spacebar

To search to, use the forward slash (/) and enter the string.

To quit man page, press q

If you like to have extensive manual page, use info command as below.

To navigate use the arrow keys and press q to quit reading.

Using apropros

Another helpful commands for accessing documentation, you can use the apropos command. Example as below:

The man -k command is provide same output as apropos.

Using whereis

Another handy command to find a command and its documentation. You can use the whereis command. Example as below.

The command output show the location of top command documentation. top command display Linux processes like CPU, RAM, running program/services.

.::End of post::.

Understanding Ubuntu Distribution Version and Kernel Numbering Schema

Every operating system have numbering system to differentiate the release date and the version. For Ubuntu, we need to know tow numbering which is distribution version and kernel numbering.

To get the distribution version, use below command:

  • uname -v

To get the kernel numbering, use below command:

  • uname -r

Below show the result.

Here the explanations for 20.04

  • The Ubuntu was release on April 2020.
  • The code for this OS is Focal Fossa.
  • Since this OS is LTS (Long Term Support), the next OS with LTS will be on April 2022 (Every two years).
  • LTS are intended for production use.
  • More details here.

Here the explanation for 5.8.0-48.generic

  • 5 – Major version
  • 8 – Minor version
  • 0 – Patch level
  • nn.generic – Developer patch level.

Ubuntu 20.04 – Update and Upgrade

Update and upgrade activities are to ensure the system received latest security and bug fixes either for operating system or application.

In this post, I will show how to perform and update and upgrade using command line.

Here the steps:

Click the menu at the bottom and at type terminal at the search box.

Click on Terminal.

Before that update/upgrade, record the details of the version and release.

To get those information use command below:

  • uname -v
  • uname -r

To get check the update, type below command

  • sudo apt update

Once the checking complete. You will see the number of packages can be upgraded.

To upgrade the software use command below:

  • sudo apt full-upgrade

The full-upgrade ensure that any-dependencies that needed will be installed, even if major changes are needed. You can also use the option upgrade even isn’t as smart as full-upgrade, but it might be a better choice on a production server because upgrade does not make major changes to software installations.

Below show the upgrade process is complete.

I run again the below command to check any changes on the version of operating system.

  • uname -v
  • uname -r

After verified, there is not changes after the full-ugprade action.

Install Ubuntu 20.04 LTS

Ubuntu is an operating system based on the Linux kernel. Ubuntu released its first version in October 2004. Ubuntu itself is based on Debian. In this post, I will show on how to install Ubuntu 20.04 LTS.

The operating system can be download here.

Here the VM Steps:

  • CPU: 1 CPU & 2 Cores
  • RAM: 4 GB
  • Storage 25 GB
  • Network: 1x1Gb

Here the installation steps:

Load the Ubuntu 20.04 LTS ISO to the virtual machine.

Run the virtual machine.

The installation interface is ready. Click Install Ubuntu.

Select your prefer Keyboard Layout. Click Continue.

Choose the installation type and click Continue. I choose

Click Install Now. This will use entire disk for operating system.

Here the disk partition summary. Click Continue.

Select you location. Click Continue.

Complete the details and click Continue.

Wait until the installation complete.

The installation is complete. Click Restart Now.

Eject the ISO/DVD and press Enter.

The reboot process is complete. Select the user and login.

Here the interface of Ubuntu 20.04 LTS.

Great the installation is completed. Let’s continue with software update/upgrade.

Create a Domain User

In this post, I will share on how to create a new domain user. Normally when a new user joining the company, they will provided a username and password to login into the domain environment. This allow user to use that system or application of that company. Beside that company can monitor all the user activity in the domain environment.

Here the steps for create a new domain user:

  • Open Active Directory Users and Computers.
  • Expand the hadiyahyalab.com and select User.
  • Right Click > New > User
  • Complete the details required and click Next.
  • Complete the password section and select the parameter if needed.
  • Click Next.

The user is created. Click Finish.

Go to any joined computer in the domain and login with new user.

« Older Entries Recent Entries »