Please enable JavaScript.
Coggle requires JavaScript to display documents.
How Linux works - Chapter 1 (Intermediate Commands (grep (grep root…
How Linux works - Chapter 1
Directory Commands
cd
Change directory
mkdir
creates a new directory
rmdir
remove an empty directory
rm
Remove an un-empty directory
Intermediate Commands
grep
grep
root
/etc/passwd
:
prints the lines in file
that
matching text
more and less
help to view a long text files
pwd
print working directory
diff
See the difference between two files
file
To see file's format
head and tail
To see the first or last 10 lines of file
sort
quick sort
Shell and Environment variables
Shell variables
are temporary variables which store values of text string
VAR=ahihi
assign a value to shell variable
keeping track of state in scripts
controls the way the shell behaves
Environment variables
are in environment variables storage
use for configuration and options
run export after created shell variables to use
VAR=ahihi
export VAR
PATH
is specical environment variables
contains
command path
is a list of system directories
the shell looks in it when locate a command
Basic Commands
rm
remove a file
touch
if the file exists,
touch
will update timestamp
creates a new file
mv
mv
file1 ... fileN dir
: move all files to
dir
directory
if
file2
exists,
file1
will renames to
file2
and replace the old
file2
mv
file1 file2
: renames
file1
to
file2
cp
cp
file1 file2
: copy contents of file1 to
file2
cp
file1 ... fileN dir
: copy all files to
dir
directory
ls
-a
list all files ( include .file) in working directory
ls
example_directory
:
list the contents of specific directory
-F
: display file type information
-l
: display long listing ( include the permissions )
list the contents of a directory
cat
file1 file2
cat
prints and concatenates
the contents of one or many files
if U don't specify any input files,
cat will reads any input type from keyboards
man
manual pages for each commands
Text Editors
vi
gedit
emacs
nano
Shell Inputs and Outputs
redirection >
send output of command to file
cat file1 > file2
append output to a file
cat file1 >> file2
pipe |
send output of first command
to input of another command
standard error
additional output steam
use for diagnostics and debugging
ls: /fffffffff: No such file or directory
ls /abgcknf > f 2> e
send standard output to file
f
send standard error to file
e
2 is steam ID (standard errors)
Special Character
https://goo.gl/KNosM4
Commands Line Keystokes
https://goo.gl/V7Vnbz
Common Errors
No such file or directory
when access the file that doesn't exist
File exists
when create the file that does already exists
Not a directory
when use a file likes a directory or
a directory likes a file
No space left on device
out of disk space
Permission denied
when try to read or write the file or
directory that you're not allowed
Operation not permitted
when try to kill a process that you don't own
Processes
type
ps
to see a list of process
has a numeric process ID
is running program
Killing process
send
signal
with
kill
command
default signal is
TERM
other
signals
-STOP
-CONT
kill
pid
Background Processes
Run a process in the background state
using ampersand
&
:warning:
if program read something from standard input, it can freeze or terminate
File mode and Permission
File modes
https://goo.gl/Nfdvso
:warning:
Sometime executable has an
s
: setuid
:
Modify Permission
chmod
chmod g+r file_name
set readable (r) permission of group (g) to file
remove permission
Using minus (-) instead of plus (+)
Absolute permission modes
https://goo.gl/DXKxbP
Symbol Links
is a file which point to another file or directory
it looks like shortcut in Windows
ln -s
path_target link_name
Archiving and Compressing Files
GNU zip (gzip)
gzip file_name : compresses file
guzip to exact file
:warning: gzip just compress a file, does'nt pack many files and directories
#
tar
tar cvf archive.tar
file1 file2 dir1
: creates archive file to contains all files and directories
tar xvf archive.tar
:exact archive file. Doesn't remove archive file
tar tvf archive.tar
: check table of content in archive file
unzip tar.gz
gzip -dc archive.tar.gz | tar xvf -
gunzip archive.tar.gz
tar xvf archive.tar