Learn to write your first shell script

Learn to write your first shell script

Learn to write your first shell script to print “Helloworld”?

Come lets Learn to write your first shell script will be the baby step for learning shell programming.

Any programming language or script it be, start it with “Hello world”.

Why start with Hello world?

Writing your first program to print “Hello world”, will allow you to learn the basic setup of the environment, configurations, and more.

https://youtu.be/yxmI8pS2wN0

hello_world.sh

#!/bin/bash
echo "Hello world"

Save the file, then to run open the terminal, and type ./hello_world.sh

PS: You might get permission denied error, due to hello_world.sh file not having execute permission for any users.

Use “chmod +x hello_world.sh” to provide execute permission.

This first line (#!/bin/bash or #!/bin/sh) has a name. It is known as ‘she-bang‘ (shabang). This derives from the concatenation of the tokens sharp (#) and bang (!).

It is also called as sh-bang, hash-bang, pound-bang or hash-pling. In computing, a she-bang is the character sequence consisting of the characters number sign and exclamation mark (#!) at the beginning of a script.
Learn to write your first shell script
~3Minutes: Tutorial

Check disk usage in unix terminal?

How to check disk usage in unix terminal?

Here is how you can check disk usage in unix terminal.

Disk usage is a critical thing in servers, Certain times the web service or server acts weird and it could be disk space being full.

In order to check the disk space we can use “df” command in unix. which will show us the disk/file system, used and available disk quantity. also the mount location of the disk.

We have discussed below listed commands

  1. df – disk usage checking
  2. man – man is nothing but manual, by passing the command as parameter to this command will open the manual for the command in parameter.
https://youtu.be/kqVzUOZMSY0

df command

aryanz_co_in@pop-os:~$ df -h
df: /run/user/1001/doc: Operation not permitted
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.6G  2.1M  1.6G   1% /run
/dev/sda2       723G  111G  575G  17% /
tmpfs           7.8G   87M  7.7G   2% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/sda1       1.5G  199M  1.3G  14% /boot/efi
Check disk usage in unix?
~3Minutes: Tutorial

How to create a file in unix – 3Minutes: Tutorial

In this video, I have explained How to create a file in unix?

(Create, edit, view and save text file using unix terminal.)

This video covers the below listed commands

  1. pwd – present working directory
  2. cd – change directory
  3. touch – to create file
  4. cat – view content of the file
  5. less – same as cat command, but opens in editor
  6. mkdir – make or create directory
https://youtu.be/xDe6OLATxQc

How to create a file in unix ?

aryanz_co_in@pop-os:~/dev/folder1$ touch hello.txt
aryanz_co_in@pop-os:~/dev/folder1$ vi hello.txt
[Edit the file] to save press Esc + :wq (w is for save and q is for quit)
aryanz_co_in@pop-os:~/dev/folder1$ cat hello.txt

Keep the learning short, not to waste your precious time.

How to create a file in unix - 3Minutes: Tutorial

Please disable your adblocker or whitelist this site! We Provide Free content and in return, all we ask is to allow serving Ads.

Pin It on Pinterest