This Blog will familiarize you with the basic linux commands. The practice section in the bottom of this page will explain how to use it in the simplest way
Explanations for commands
cd /
|
Go to root folder
|
open /
|
open root folder
|
folder Structure
|
Root —> User —> Current (home directory) bkrishnankutty {root is MatichoshHd}
|
ls
|
ls :- list all the files and folders expect hidden files. ls -a command is used to see all files including hidden files . ls is the command and -a is the option . ‘.’ file names proceeded with dot are hidden
ls -d */ and ls -d */*/ :- List all the directories and subdirectories in a folder
|
. and ..
|
. means current directory cd . And .. means parent directory cd ..
|
~
|
Home directories can also be referred to by the tilde ~ character. try ls ~/.. and ls ~/.
|
copy file
|
cp /Users/bkrishnankutty/protractor-design.png . Don't forget the dot (.) at the end. Remember, in UNIX, the dot means the current directory
|
Listing files and directories
ls
|
list files and directories
|
ls -a
|
list all files and directories
|
mkdir
|
make a directory
|
cd directory
|
change to named directory
|
cd
|
change to home-directory
|
cd ~
|
change to home-directory
|
cd ..
|
change to parent directory
|
pwd
|
display the path of the current directory
|
Vim
vim filename
|
Open a text file with Vim editor. When you open file, it will be in cmd line mode
|
Insert line mode
|
i
|
Last line mode
|
: {v -visual mode <vj combination for select>}
|
exit insert mode
|
esc {Command line —>Insert mode —> Last line —> Command mode}
|
New Tab in Vim
|
|
Close the Current Tab
|
|
undo & redo
|
|
Cursor movement
|
h -left , l - right , j- up and k - down
|
Existing
|
|
|
|
copy :-yy, 2yy
delete/cut :-dd,2dd
paste :p, 2p or put
|
Files and Directories
cp file1 file2
|
copy file1 and call it file2 .cp /vol/examples/tutorial/science.txt .
|
mv file1 file2
|
move or rename file1 to file2 mv science.bak backups/.
|
rm file
|
remove a file rm tempfile.txt
|
rmdir directory
|
remove a directory rm -r tempdir
|
cat file
|
display a file cat science.txt
|
more file
|
display a file a page at a time less science.txt <space bar>
|
head file
|
display the first few lines of a file head -5 science.txt <default 10>
|
tail file
|
display the last few lines of a file tail -5 science.txt <default 15>
|
grep 'keyword' file
|
search a file for keywords grep Science science.txt
-v display those lines that do NOT match
-n precede each maching line with the line number
-c print only the total count of matched lines
-i ignore case
grep -ivc ‘science top' science.txt
|
wc file
|
count number of lines/words/characters in file
|
Redirection or Outputs
command > file
|
redirect standard output to a file cat > list1
|
command >> file
|
append standard output to a file cat >> list1
|
command < file
|
redirect standard input from a file sort < biglist > slist
|
command1 | command2
|
pipe the output of command1 to the input of command2
|
cat file1 file2 > file0
|
concatenate file1 and file2 to file0 cat list1 list2 > biglist
|
sort
|
sort data sort < biglist > slist
|
who
|
list users currently logged in
|
a2ps -Pprinter textfile
|
print text file to named printer
|
lpr -Pprinter psfile
|
print postscript file to named printer
|
1) What is a Linux kernel
2) What is a shell :- http://prntscr.com/bt2kue
3) Everything in UNIX is either a file or a process.
4) What is a file and Process
5) Directory structure of unix :- All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root.
Practical
*Problem Statement
Practical
*Problem Statement
- Make to directory "Google"
- Make 2 sub directory 'TestA' and 'TestB'
- Go to TestA and create files 'FileA.txt' and 'FileB.txt'
- use Vim and copy paste Just data into file 'FileA.txt'
- Copy contents of 'FileA.txt' to directory 'TestB'
- Rename File in 'FileA.txt' to 'TestOnly.txt'
- search for String say"Object" in file 'TestOnly' and output to a new file 'searchResult'
- Display contents of a file 'TestOnly'
- Display contents of a file 'TestOnly' and view as pages
- Display first 2 pages of a file 'TestOnly'
- Display last 2 pages of a file 'TestOnly'
- get the count of characters in the file and the line number 'TestOnly'
- Create a file with 5 students and sort it using linux commands
- Remove file 'TestOnly'
- Remove folder 'TestB'
- Find a directory or file in your machine
- Find a Applications Process ID
- Kill an Application
- To get a more complete picture of the processes on this system, run the following
- Easiest way to find out what processes are running on your server is to run the command
No comments:
Post a Comment