
Learn Linux in 30 minutes
Linux — Operating system (collection of software that manages hardware and provides an environment where application can run)
- Kernel
Linux is not UNIX derivative
1.Linux directory structure
/ Root, the top of the file system hierarchy
/bin Binaries
/etc System configuration files (config files control how OS or apps behave)
(Slides)
2.The shell
Shell — is default user interface for Linux system
- command line interface
SSH — secure shell
$ — normal user
root@linuxsvr# — super user
Root is powerful. Restricteed to system admin
3. Basic linux commands
cat — content of the file
echo — content of variables
man ls — learn about command
pwd, echo
mkdir -p mon/s/a. (Create 3 directories)
Rm -rf [directory name] — recursively delete (with files inside)
vim file.txt. — create
4. Listing files
Ls -F — files
Chmod — change mode command (change permissions)
chmod u+rwx,g-x sales.txt
chmod u=rwx,g=rx sales.txt
777 for directories | 666 for files
-rw-rwxr- — User|Group|Others
5. View files
cat — view files with static content
tail -15 file.txt — displays last 15 lines (10 by default)
head -2 file.txt — displays first 2 lines (10 by default)
More file.txt
less file.txt
[enter] — 1 line down
[space] — multiple lines down
VIM/VI
i — insert at the cursor
I — insert at the beginning
x — delete character
dw — delete a word
dd — delete a line
u — undo
ctrl+R — redo
/<pattern> — start forward search (n — move to another position )
?<pattern> — start reverse search
:x — save and delete
6. Finding files and directories
find . -name s* -ls
find . -size +1
find . -type d -newer 233.txt
locate faster than find, but it’s not in real time
touch — create a file
7. Removing files
Rm file — remove file
Rm -r dir — remote the directory and its contents
8.Copying files
cp source_file destination_file
Cp src_file1 [src_fileN …] dest_dir — copy source_files to destination_directory
Cp -r source_directory destination_dir — copy src_dir recursively to destination
Diff file1 file2
9.Copying files
cp source_file destination_file
Cp src_file1 [src_fileN …] dest_dir — copy source_files to destination_directory
Cp -r source_directory destination_dir — copy src_dir recursively to destination
Diff file1 file2
10. Move
mv — move or rename files and directories
Mv file1 file2 — file 1 will be renamed
Mv source destination
mv -i source destination (interactive mode)
11. Sort
sort file1.txt
Sort -ru — reverse order
12. Wildcards
Ls *.txt
Ls a*
Ls a*t
13. Comparing
Diff
Stiff
Vim diff
14.Searching in files
Grep [string] [filename]
Grep -v [string] [filename] — invert match
Grep -i — perform a search ignoring case
Grep -ci [string] [filename] — count
File [filename] — information about file
