Linux Commands Part 5 - 8
Tags: linux-com-book
What are commands
An executable program
A program built into the shell itself
A shell function
A alias
Commands
to know command is of which type :
type commandto the exact location of executable :
which lsin bash, to get info regarding shell built-ins :
help cdto display program’s manual page :
man programto search the list of man pages for possible matches based on a search term
-> apropos partition
#output :
addpart (8) - tell the kernel about the existence of a partition
cfdisk (8) - display or manipulate a disk partition table
cgdisk (8) - Curses-based GUID partition table (GPT) manipulator
delpart (8) - tell the kernel to forget about a partition
fdisk (8) - manipulate disk partition table
...to display one-line manual page description :
whatis lsalternative to man page :
info coreutilsto create alias command :
alias foo=”cd programm && code .”
Input Output Commands
to redirect standard output to a file :
[me@linuxbox ~]$ ls -l /usr/bin > ls-output.txt“>” also clears the whole file and adds the new content
“>>” will append the content to the file at the end
Error message aren’t send to file unless specified in the command, they are sent to standard error
There are 3 types of file streams
Input
Output
Error
Pipelines
The capability of commands to read data from standard input and send to standard output.
to view a long output :
ls -l /usr/bin | lessPipelines are used along with filter
Ex :
ls -l /usr/bin | sort | less
The Difference Between > and |
Simply put, the redirection operator connects a command with a file, while the pipeline operator connects the output of one command with the input of a second command.
uniqis used to remove duplicate lines, mostly placed after sortwc: to print Print Line, Word, and Byte Counts :wc names.txtgrep to filter out using keyword :
ls /bin /usr/bin | sort | uniq | grep zipheadto print the first part of file-n xto print first/last x lines
tailto print the last part of file-fto keep watching file for changes
tee: program reads standard input and copies it to both standard output (allowing the data to continue down the pipeline) and to one or more files
The world of Echo
print something to terminal
Arithmetic Expression
Brace Expression
use “” to print the string as it is
use ** to as escape character
!200will give the command in history at line 200
Last updated
Was this helpful?