Showing posts with label linux commands. Show all posts
Showing posts with label linux commands. Show all posts

Monday, January 30, 2017

Basic Linux Commands Part2



Hi guys! In previous article, I described you about some basic commands and editors of Linux. If you are new to this series you can read that from below link-
Most of us are well familiar with windows OS. Linux is also good platform. If you will start working on it, you will realize it.
Note : Most of the issues in Big Data came from Linux security section. I will try to cover it too. Today we will learn new topics under Linux basics. Be careful, Linux is case sensitive.
echo command:
                This is used to print some statements.
                Eg. user@machine:~$echo “This is sample statement by vimal”

We have few concepts for defining and saving standard input, output and error.
0 – for standard input
1 – for standard output
2 – for standard error
Please look into below image to understand it - 





Mail command:
To send a mail, we will use mail command.
user@machine:~$ mail –s”This is subject” user<messagebody.txt

grep command:
                grep is searching finding filtering tool. It can do things like pattern matching  & mapping
                eg. user@machine:~$ grep sometext file.txt
                       user@machine:~$ grep sometext ./*
                       user@machine:~$ grep sometext ./* | unique | cut –d: -f1



Pipes & Directional operators:
è user@machine:~$Program1 | Program2
§  This means output of program1 works as input for program2
§  Eg.
§  user@machine:~$ ps aux                             (to check processes)
§  user@machine:~$ ps aux | less | uniq | sort
è user@machine:~$Program1 && Program2
§  This means when program1 true then program2 execute
§  Eg.
§  user@machine:~$ ls filenotexist.txt && echo “Unsuccessful”

Package management with apt-get:
                apt-get mainly used for installation of softwares, packages
§  user@machine:~$ apt-get update
o   It may prompt permission denied. To avoid this we will use-
§  user@machine:~$ sudo apt-get update
§  user@machine:~$ sudo apt-get upgrade
§  user@machine:~$ sudo apt-get install  <applicationname>
o   To install any software or application
§  user@machine:~$ apt-cache search editor
o   To find editor
§  user@machine:~$ sudo apt-get remove  <applicationname>
o   To remove software or application








Tuesday, September 13, 2016

Basic Linux Commands Part1

Hi guys, I am writing series of article on Big Data. Industry mostly uses Linux or Unix for deploying their Big Data solution. So here I am covering some basics of Linux-

In Linux most of the work is done with command prompt, for this we use terminal. Other works are done with editors, it is same like notepad in windows.
Please find some useful commands and their use-

Sno.
Command
 Use
1
pwd
Print working directory
2
ls
List
3
ls -a
All listing
4
ls -al
All listing having permission to user
5
ls -alh
Human readable a long listing like 4 KB size
6
cd <directory>
Change directory
7
mkdir <dirname>
Make directory
8
mkdir -p <coolfolder/child/nested>
To create complete path
9
ls Desktop/Coolfolder<tab>
To get data
10
rm -r coolfolder
Remove recursive
11
rm -I coolfile.txt
To notify for remove
12
man <command>
Help or knowledge
13
touch <filename>
To create a file
14
mv tet.txt somefolder/
To move file
15
cp somefolder/text.txt /testcopy.txt
To copy
16
mv test.txt newName.txt
To rename
17
cd ..
Move up a dir
18
cd ../..
Move two up
19
cd <home/username>

20
cd ~
To home dir
21
cat <filename>
To read file
22
cat <filename1> <filename2>
To concat two files output


Editors :

1.      nano <filename>
                                                              i.      use ^X  (ctrl+X) to exit, it will prompt to save the file
                                                            ii.      ^W to search some data
2.      vi <filename>
                                                              i.      for creating files
                                                            ii.      for modifying & appending some text on already existing file
                                                          iii.      for displaying the content of file
                                                          iv.      use :wq to save and exit
                                                            v.      :q! to exit without save

Note : vi editior works on three modes
            Esc mode (Press Esc)
            Insert mode (Press i)
            Colon mode (press shift + ;)
3.      emacs <filename>
                                                              i.      Fast & mostly used by programmers
4.      vim <filename>
                                                              i.      Secure & mostly used by sysadmins



Cat command:
            This is one of the important command. It is mostly used for displaying the file contents, but it has so many other uses too.

o   cat>                 for creating files
o   cat>>               creating files if it is not exit or appending extra text if it is already exist

user@machine:~$ cat > file.txt
Write your content here
o   Press ctrl+d to save and exit
o   Press ctrl+c exiting file without saving
o   But you can’t change the content in previous line