A Brief Introduction to UNIX Commands in Linux

Benedictusbayuc
4 min readApr 19, 2020

--

Linux History

Linux is an open source UNIX-like operating system. The history of Linux begins with the development of a system called Unix by Ken Thompson and Dennis Ritchie from AT&T Bell Labs, in 1968. Bell licensed the operating system to a number of institutions, one of which was to the Department of Computer Science at the University of Berkeley, California, which eventually produced several Unix clones with the BSD (Berkeley Software Distribution) code. Professor Andrew Tanenbaum has developed a Unix operating system that can be used on personal computers, Minix ( Mini Unix). However, this system did not have all the Unix functions that students wanted at the time, especially for students named Linus Torvalds. Linux emerged in 1991 which was developed by a student named Linus Torvalds with the aim of making a free operating system with capabilities like Unix but compatible with PCs. In September 1991, Linux was first launched with the source code length of 10,239 lines version 0.01. Linux distributed under GNU General Public License. The license allows distribution or even the sale of modified versions of Linux but with a note that all distributions must be under the GNU GPL license and must be with the source code of the program. That’s why Linux belongs to UNIX-like system.

Let’s Get Started

Picture above list several basic Unix command. Let’s start with a basic task: make a file. But before we start, In this article I use Google Colab to run Unix command because I don’t have Linux OS on my laptop so I make some adjustments, normally we use Unix Command in Linux Terminal.

Make a File and Content

First we make sure we’re in the right work directory. We use command pwd to see our work directory, like shown in the picture below.

Okay, my work directory is in ‘content’ folder. There are several ways to make a file and it’s content.

  • Touch command

We could use touch command with syntax like touch <file name>. This will create an empty file. (Remove the ‘!’ mark if you run it in Linux terminal).

As you could see, I make a text file called hello.txt, and I used ls command to see the list of files and folders in my work directory, and my file was created.

  • somecommand > path/to/file

With this command we could also write the command we want inside the file. For example:

We could see that inside hello.txt we managed to write ‘Hello Guys’ from echo command.

  • Use nano or another text editor

We could use nano command with syntax nano path/to/file or with another text editor like gedit like gedit path/to/file.

Copy and Rename a file

Sometimes organizing files could be a complicated job. Copy and rename are some common commands in Linux.

The syntax is cp path/to/file_origin /path/to/file_destination. You could rename the file directly by changing the file name in file_destination.

Create a Directory and Move a File

Create directory is one of the most important tasks. To create directory, use mkdir path/to/dir/ command.

To move file, use mv /path/to/file_origin /path/to/file_destination. Also, we could rename the file by changing the file name in file_destination.

Remove Directory

To remove directory, we could use rmdir dir1 dir2 … command. But this command could only remove an empty directory. If you want to remove directory with the files within, use rm -r dir command.

You’ll get this error if the directory is not empty.

with rm -r, I managed to remove ‘my_dir’ directory with the files.

--

--