To show now time on Ubuntu

To display the current time on Ubuntu, you can open the terminal and use the date command.

Simply type the following command in your terminal:

1
date

This will show the current date and time in the format of Day Month Date Hour:Minute:Seconds Timezone Year.

If you want to display the time in a specific format, you can use the + sign and a specific format string. For example, the following command will display only the current time in the HH:MM:SS format:

1
2

date +%T

You can also display the time in a 12-hour format with AM/PM by using %r like this:

1
2

date +%r

If you want to display the time continuously updating in the terminal, you can use the watch command. For example, the following command will update the time every 1 second:

1
2

watch -n 1 date +%r

This will display the date and time in the HH:MM:SS AM/PM format, updating every 1 second. You can adjust the update frequency as per your requirement by modifying the -n option.

How to calculate the size of the current folder on Ubuntu?

You can use the du command to calculate the size of the current folder in Linux. The du command stands for “disk usage” and it gives you information on the amount of disk space that a file or directory is occupying.

To calculate the size of the current folder, simply navigate to the directory in the terminal and run the following command:

``
du -sh

1
2
3
4
5
6
7
8
9
Breaking down the options used in the command:

-s option displays only a total for each argument
-h option prints human-readable sizes, such as 2.5K, 1.2M, etc.
. is used to specify the current directory
This will output the size of the current directory in a human-readable format.

If you want to see the size of every file and subdirectory in the current directory, you can use the following command:

du -h

This command will list the size of every file and subdirectory in the current directory, in a human-readable format.

How to check the load of the hard disk on Linux?

You can use the iostat command to check the load of hard disk on Linux. iostat stands for Input/Output statistics and is a part of the sysstat package which is pre-installed on many Linux distributions.

To check the load of hard disk, run the following command in the terminal:

1
2
3
sudo apt-get install sysstat

iostat -h
1
2
3
4
5
6
7
8
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
0.09 0.01 0.05 0.00 0.00 99.85

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
loop0
0.00 0.00 0.00 8 0
sda
0.21 0.60 7.87 2814999 37241133

How to check the usage of the hard disk

You can use the following command to check the usage of the hard disk on Ubuntu 16.04:

df -h

1
2
3
4
5
6
7
8
9
10
Filesystem      Size  Used Avail Use% Mounted on
udev 483M 0 483M 0% /dev
tmpfs 101M 14M 88M 14% /run
/dev/sda2 52G 9.1G 42G 17% /
tmpfs 504M 0 504M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 504M 0 504M 0% /sys/fs/cgroup
/dev/sda1 361M 162M 181M 48% /boot
tmpfs 101M 0 101M 0% /run/user/1000

This command will show the usage of the hard disk in a human-readable format. The -h option makes the output in sizes that are easier to read, such as “3.5G” or “75M”.

This command will show you the usage of all mounted hard disks on your system.

You can also use the following command to check the free space available in your hard disk:

du -sh /

This command will show you the amount of space used by files and directories in the root directory (i.e., the top-level directory) of your file system.

You can replace the “/“ with the directory you want to check the space usage for.

How to check the usage of memory?

To check the usage of memory in Ubuntu 16.04, you can use the following command in the terminal:

free -m
This command will display the amount of free, used, and total memory available in the system in MB (megabytes). Specifically, the output of this command shows:

Total: the total amount of RAM available in the system.
Used: the amount of RAM currently in use.
Free: the amount of RAM currently not being used.
Shared: the memory being used by shared libraries.
Buffers: the memory being used by the kernel to cache data from disk.
Cache: the memory being used by the kernel to cache data from disk and file systems.
Here’s an example output of the free -m command:

1
2
3
4
               total        used        free      shared  buff/cache   available
Mem: 7981 1161 4663 19 2156 6438
Swap: 8079 0 8079

In this example, the system has 7981 MB of total memory available, 1161 MB of which are currently in use, 4663 MB are free, and 2156 MB are being used as cache memory.y.

TaskList in Linux

How to display a task list in Linux

Use the following command to display the task list.

  1. The “top” command: displays the running process in real time. Displays CPU, memory usage, process status, and so on. You can quit by pressing Ctrl + C.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    top - 20:07:45 up 22:48,  1 user,  load average: 0.39, 0.24, 0.19
    Tasks: 198 total, 1 running, 197 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 4.8 us, 3.0 sy, 0.0 ni, 92.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem : 8038780 total, 1191088 free, 4469544 used, 2375148 buff/cache
    KiB Swap: 8265724 total, 7867900 free, 397824 used. 2816892 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    2077 root 20 0 21820 3376 2892 S 3.5 0.0 2:20.91 systemd-jou+
    2364 root 20 0 1284476 137332 23416 S 2.5 1.7 23:22.43 VirtualBox
    3529 john 20 0 728836 27360 12672 S 2.5 0.3 0:18.11 xfce4-term+
    693 root 20 0 72200 2984 2396 S 1.5 0.0 0:00.37 irqbalance
    892 root 20 0 154664 6788 4076 S 0.7 0.1 0:53.64 upowerd



  2. The “PS” command: list the currently running processes. You can use some options to focus on specific information or filter the state of the process.

“PS aux” displays all the currently running processes. “PS aux grep < process name >” searches for a process that matches the specified process name.

  1. “Htop” command: a task management tool, such as top command, can display a list of processes and end the process.
    You can use these commands to display the task list.

How to set a static IP address on Ubuntu 16.04?

You can follow these steps:

Open the terminal by pressing Ctrl+Alt+T.
Type the command “sudo vi /etc/network/interfaces” and press Enter. This will open the “interfaces” file in the vim text editor with root privileges.
Find the line for the network interface you want to configure (e.g., “iface eth0 inet dhcp”) and replace “dhcp” with “static”.
Add the following lines with your desired IP address, gateway, and subnet mask:

address 192.168.0.12
netmask 255.255.255.0
gateway 192.168.0.1

Save and close the file by pressing Ctrl+O, Enter, and then Ctrl+X.
Restart the networking service to apply the changes by typing the command “sudo service networking restart” and pressing Enter.
Your network interface should now have a static IP address. You can confirm the change by using the “ip addr show” command.d..

How to show the ip address on Ubuntu 16.04?

To get the IP address on Ubuntu 16.04, you can use the following steps:

Open the terminal by pressing Ctrl+Alt+T.
Type the command “ip addr show” and press Enter.
Look for lines starting with “inet” and followed by an IP address; typically “inet” lines have an IP address for each network interface on your machine.
Your IP address will be listed next to “inet” on the interface you are using to connect to the internet.

1
2
3
4
5
6
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.0.121/24 brd 192.168.0.255 scope global eth1
valid_lft forever preferred_lft forever

Note: you can also use the “ifconfig” command to get the IP address of your network interface, but this command is deprecated and not installed by default in Ubuntu 16.04.

How to understand the Linux file system?

  1. Understand the basic directory structure:
    Linux has a hierarchical file system, which starts with the root directory. All other directories are located under the root directory. The basic directory structure includes directories like /bin, /etc, /home, /usr, and /var.

  2. Know the commands to navigate and list directories:
    The basic commands to navigate and list directories are cd, ls, pwd, and tree. For example, “cd” is used to change directories, “ls” to list files and directories in the working directory, “pwd” to print the current working directory, and “tree” to display the directory structure in a tree-like format.

  3. Understand the permissions and ownership of files and directories:
    Every file and directory in Linux has an owner and permissions that control who can read, write, and execute them. The basic commands to modify permissions and ownership are chmod, chown, and chgrp. For example, “chmod u=rw,g=r,o=r filename” changes the permissions of the file named “filename” so that the user can read and write the file, and group members and others can only read it.

  4. Know the different file types:
    Linux has different file types such as regular files, directories, symbolic links, sockets, and device files. Each file type has its own properties and is used for a specific purpose. For example, regular files hold data, while symbolic links serve as a pointer to another file or directory.

  5. Understand the file system hierarchy standard:
    The Filesystem Hierarchy Standard (FHS) defines the directory structure and the contents of files and directories for Linux systems. It provides a standardized approach to organize and manage files in Linux systems.

  6. Understand the importance of mount points:
    Mount points are directories used to access different file systems. When a file system is mounted on a directory, it becomes part of the file system hierarchy. The mount command is used to mount a file system on a directory. For example, “mount /dev/sda1 /mnt” mounts the partition on /dev/sda1 to the directory /mnt.

By following these steps, you can gain a good understanding of the Linux file system, which will help you to manage files and directories effectively.