Six months into my new career in Hamon Technologies as a programming trainee, I was given a wonderful opportunity to join the Lycaeum mentoring program. I sincerely thank Mr. Noufal Ibrahim and Mr. Asif E T V for providing me the same, along with my job.
Actually, me and a few of my colleagues had already undergone a crash course in Basic Unix commands six months prior to joining Hamon. That was the first time I heard about "Unix shell and it's commands".
As a pre-requisite, we had installed Ubuntu back then. During the crash course we were introduced to the book " The UNIX Programming Enviroment" by Brian W Kernighan & Rob Pike.
Eventhough I was familiar with the shell and some of its commands and most of my work ran on the shell, but I always lacked a clear idea about what these commands actually did and how to use them properly & wisely.
On joining this mentoring class, I got a better knowledge about the Unix file systems, its directory heirarchy, and its commands. Noufal Sir had asked us to read the first five chapters of " The UNIX programming environment " which comprised of the basic UNIX commands, shell scripting and a lot more. I have completed the first two chapters and still needs to cover three more.
Now I am able to write small shell scripts which became more useful in my career.
Some of the basic commands which are commonly used are listed below:
man - View manual pages for Unix commands
clear - Clear screen
history - Show history of previous commands
mkdir - Make directory
cd - Change directory
ls - List files and directories
cp - Copy files
rm - Remove files and directories
mv - Rename or move files and directories to another location
chmod - Change file/directory access permissions
who - Find out who is logged into the system
ps - Lists processes
kill - Terminate a process (stop application running)
cat - Concatenate files and show contents to the standard output
head - Shows the first 10 lines of text file (we can specify any number of lines)
tail - Shows the last 10 lines of text file (any number can be specified)
grep - Searches a file for words that have a specified pattern
sort - Sorts the file
pipe ' | ' - Pipe send the output of one command as input of another command.
and a lot more
It's already been three weeks, since our class had started. Two weeks back we each had a presentation based on a particular UNIX command. My topic was based on the 'find' command.
Below is a short description about the same.
find - It can be used to find files and directories and perform subsequent operations on them. It supports searching by file, folder, name, creation date, modification date, owner and permissions.
$ find [where to start searching from] [expression determines what to find] [-options] [what to find]
Consider the following tree hirerachy :
1. Search a file with specific name / pattern
$ find ./GFG -name sample.txt
It will search for the file 'sample.txt ' in GFG directory and '-name ' is the expression
$ find ./GFG -name *.txt
It will give all files which have '.txt ' at the end.
2.Search for empty files and directories.
$ find ./GFG -empty
This command finds all empty folders and files in the entered directory or sub-directories.
3.Search for file with entered permissions.
$ find ./GFG -perm 644
This command finds all the files in the GFG directory or sub-directory with the given permissions.
There are lots of operations which can be performed using the 'find' command.
In short, 'find' Command in Unix returns all files below the current working directory. Further, find command allows the user to specify an action to be taken on each matched file.
That is all about the Unix , I am still learning more about shell and its commands.
I will be giving the updates on weekly basis.