Some Basic Useful Unix Console Commands
Some Basic Useful Unix Console Commands: mkdir, echo, pwd, alias,cat, grep, More, ls
mkdir : , etc.makes directories.
set number : Shows the line numbers
mkdir -p : makes directories without parent directory.
ls : lists your files
ls -l : lists your files in 'long format'. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.
ls -a : lists all files, including hidden ones whose filenames begin in a dot.
> : this operator assigns the left values to the right values.
the difference between > and >> operators is;
> override the data to file and the previous data will be removed.
>> writes the data to the end of file and the previous data does not effects.
But both of them assign data to the file
echo "thethings" > myFile : echo writes the things between double open quote to the myFile file
pwd : shows the path you are now at.
echo $HOME : shows the home path.
alias: instead of writing long codes you can create alias EX: alias showhome='echo $HOME' : . This code creates "showhome" alias and whenever we run this, it will show the same result as the "echo $HOME" code.
To run .exe files we should type ./ before writing the file name.
cat : Shows all the data in the file
More: Shows one page of data
<ctrl> + f : goes to next page (forward)
<ctrl> + b : goes to previous page (backward)
To Enter, Delete or Change Text (you must be in command, if not press <Esc>)
i Enter text entry mode
x Delete a character
dd Delete a line
r Replace a character
R Overwrite text,
press <Esc> to end
mkdir : , etc.makes directories.
set number : Shows the line numbers
mkdir -p : makes directories without parent directory.
ls : lists your files
ls -l : lists your files in 'long format'. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.
ls -a : lists all files, including hidden ones whose filenames begin in a dot.
> : this operator assigns the left values to the right values.
the difference between > and >> operators is;
> override the data to file and the previous data will be removed.
>> writes the data to the end of file and the previous data does not effects.
But both of them assign data to the file
echo "thethings" > myFile : echo writes the things between double open quote to the myFile file
pwd : shows the path you are now at.
echo $HOME : shows the home path.
alias: instead of writing long codes you can create alias EX: alias showhome='echo $HOME' : . This code creates "showhome" alias and whenever we run this, it will show the same result as the "echo $HOME" code.
To run .exe files we should type ./ before writing the file name.
cat : Shows all the data in the file
More: Shows one page of data
<ctrl> + f : goes to next page (forward)
<ctrl> + b : goes to previous page (backward)
VI - Editor
To Enter, Delete or Change Text (you must be in command, if not press <Esc>)
i Enter text entry mode
x Delete a character
dd Delete a line
r Replace a character
R Overwrite text,
press <Esc> to end
If you have huge data in the file, so these shortcuts help you more:
<shift> + g - goes to the end of page d + $ - deletes from cursor position till the end of line
d + <shift> + g - deletes from cursor position until the end of page
:10 - goes to 10th line
:10 - goes to 10th line
:1 - goes to first line.
NEVER exit vi by clicking Q or typing ESC, EXIT, etc. Because in the background it will keep working and be a zombi into the system files.
To exit you must be in command, if not press <Esc> And type a ":" (colon) and the word you want to do below.
wq Write, then quit
q Quit (will only work if file has not been changed
wq Write, then quit
q Quit (will only work if file has not been changed
q! Quit without saving changes(force quit)
Banner: The banner command can print banners as shown in image, but it is limited you can print only 10 characters. But if you put some spaces between words so you can write more words.
$ banner ercan duman .com
GREP Command$ banner ercan duman .com
- grep people* : shows all files which include "people" in current directory.
grep -v people : shows all lines which is not include people. So it brings huge data.

Comments
Post a Comment
Ask me anything here...