Now we that we learned about shell,git and Github, we need to learn more shell commands to operate on the Linux shell system.
Before we start with this topic take a tour on the Linux system. Tour
type
We use type command to displays the kind of command the shell will execute and identifies whether this is a shell built-in command, subroutine, alias, or keyword.
alias is a command in various command-line interpreters, which enables a replacement of a word by another string.
Tip: for more info on type use man command or read type
which
We use which command to determine the exact location of a given executable.
Tip: for more info on which use man command or read which
ln
We use ln command to create links between files, like a shortcut in windows.
A link in UNIX are pointers pointing to a file or a directory and there are two types of links:-
- Soft Link or Symbolic links: is similar to the file shortcut feature which is used in Windows Operating systems,any changes to the data in either file is reflected in the other.
we create a soft link by:
ln -s <original filename> <link name>
- Hard Links: Hard links more flexible and remain linked even if the original or linked files are moved throughout the file system.
we create a hard link by:
ln <original filename> <link name>
Tip: for more info on which use man command or read ln
help
we use the help command to get extra help if you are stuck on understanding the command.
help vs man
Help is a built-in "usage" of the command, and not all commands implement it, or at least not the same way, however, man is a command by itself which is a single page that contains all information.
Tip: for more info on help command read help
man
We use man command to display the manual for each command in the shell.
The man command is really important you can find ways to solve most of Linux problems, so the man is a really so important that there is a slang for it called RTFM.
RTFM: RTFM is an initialism and internet slang for the expression "read the fucking manual" i guess some one was so mad that a programmer didn't read the manual, so RTFM.
For example you might not know that cd -
command print the previous dir and move back to the previous di,next time just checkout the manual for new things.
How to read a man page
To read a man page use this description of each concepts.
NAME a short description of what the command is doing.
DESCRIPTION a longer description of Mandatory arguments to long options are mandatory for short options too. .
SYNOPSIS will help you understated the structure of the command.
Tip: for more info on man, man the man page.
file
we use file command to determine what kind of data a file contains before we try to view it like.
.file type may be of human-readable(e.g. ‘ASCII text’) or MIME type(e.g. ‘text/plain; charset=us-ascii’).
file <file_name>
It has three sets of tests as follows:
filesystem test: The program verifies that if the file is empty, or if it’s some sort of special file.
magic test: These tests are used to check for files with data in particular fixed formats.
language test: This test search for particular strings which can appear anywhere in the first few blocks of a file.
Tip: for more info on file command file use man or read file
magic file
a magic file is used to find a file contains lines describing magic numbers which identify particular types of files.
Each line consists of four fields, separated by one or more tabs:
The first field is a byte offset in the file
The next field is a type: byte, short, long, string.
The next field is a value, preceded by an optional operator.
The rest of the line is a string to be printed if the particular file matches the template.
Example:
0 byte 0x80 OMF object file (Microsoft relocatable)
0 short 0x5A4D extended DOS executable (.EXE)
0x32 string PKWARE Self extracting Zip
How to create and use a magic file
To create a magic file we first need to create a file with a .mgc extension.
Add the argument a file that has R string at offset 0.
0 string R has r data
Then compile the magic file using:
file -C -m <your magic file>
To use you magic file type the command:
file -m <compiled magic file> *
This will output all the file that has R string at offset in the directory
Tip: for more info on magic file use the command man magic or read magic
Top comments (0)