Post on 02-Jun-2018
8/10/2019 Mysql and Sqlite Commands
1/47
sno
1
8/10/2019 Mysql and Sqlite Commands
2/47
8/10/2019 Mysql and Sqlite Commands
3/47
8/10/2019 Mysql and Sqlite Commands
4/47
8/10/2019 Mysql and Sqlite Commands
5/47
8/10/2019 Mysql and Sqlite Commands
6/47
8/10/2019 Mysql and Sqlite Commands
7/47
8/10/2019 Mysql and Sqlite Commands
8/47
8/10/2019 Mysql and Sqlite Commands
9/47
clear
exit
wc
Options can be
-c Display numer of characters.
-m Display numer of . -l Display numer of lines.
-w Display numer of words.
pwd
e.g. : DSTBoulder:dst02lp3:/content/iDI/stage/20/AssetReports$ pwd
who
who -T
who -H
who am i
whoami
file
e.g. : #file /etc/hosts
touch
rm
rm rf /Testing ----> Removes directory.
rm Bachi.txt -----> Removes the file.rm *.txt -----> Removes all the files extension with .txt.
vim or vi
cat
#cat Bachi.txt
chown
# ls l
# chown bachi Bachi.txt
# ls -l
ln
#ln Bachi.txt Bachi_ln_test.txt
8/10/2019 Mysql and Sqlite Commands
10/47
hostname :
hostname - show or set the systems host name
domainname - show or set the systems NIS/YP domain name
dnsdomainname - show the systems DNS domain name
nisdomainname - show or set systems NIS/YP domain name
ypdomainname - show or set the systems NIS/YP domain name
uname#dmesg | grep mem
#lsattr E l sys0 a realmem
#dmesg | grep cpu
#lsdev C | grep Proc
df
#df h
#df a
du:
Syntax: du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
#du h
last
Syntax:
last [-R] [-num] [ -n num ] [-adiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...]
lastb [-R] [-num] [ -n num ] [ -f file ] [-adiowx] [name...] [tty...]
#last
How to change the Shell type?
date
e.g.: date +%D
D - wholedate ,a-day name,y-year,h-monthname,m-month number,d-day of month,T-diaplays th
File Extraction Commands
Zip
Syntax : zip -9 -r desiredname.zip zipneedfile -------- it will keep the source file
or
zip -rm desiredname.zip zipneedfile -----------it will not keep the source file
unzip
Syntax : Unzip foldername.zip
User Administration Commands
useradd
e.g. useradd bhaskar
passwd
e.g. passwd bhaskar
groupadd
usermod
8/10/2019 Mysql and Sqlite Commands
11/47
8/10/2019 Mysql and Sqlite Commands
12/47
chmod
chmod +X filename.sh
chmod 777 filename.txt
chmod 400 filename.txt
#chmod R 777 Testing ---> For directories
Mysql commands
mysql -u Enliven -p -h 192.168.1.5
Show databses
use databases name
Show tables
Select count(1) from tablename;
Sqlite commands
sqlite3 Enliven.db
.tables
Select count(1) from tablename;
delete from tablename
update Tablename set fieldname='value to update' where colunm name/value=XX;
EX:update AG_Schedule set NextStart='1983-02-01' where AggId=46;
.output filename.csv + select * from table name
Shell script commands
vi filename
Insert---I , after changing press "esc" next press shf+; and press .q/.wq (w fpr save)
chmod +x filename.sh
./filename.sh
cat filename
8/10/2019 Mysql and Sqlite Commands
13/47
crontab -e
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
Run backup cron job scriptf you wished to have a script named /root/backup.sh run every day at 3am,
your crontab entry would look like as follows. First, install your cronjob by running the
following command:
# crontab -e
Append the following entry:
0 3 * * * /root/backup.sh
ave and close the file.
More examples
To run /path/to/command five minutes after midnight, every day, enter:
5 0 * * * /path/to/command
Run /path/to/script.sh at 2:15pm on the first of every month, enter:
15 14 1 * * /path/to/script.sh
Run /scripts/phpscript.php at 10 pm on weekdays, enter:0 22 * * 1-5 /scripts/phpscript.php
Run /root/scripts/perl/perlscript.pl at 23 minutes after midnight, 2am, 4am ..., everyday,
enter:
23 0-23/2 * * * /root/scripts/perl/perlscript.pl
Run /path/to/unixcommand at 5 after 4 every Sunday, enter:
5 4 * * sun /path/to/unixcommand
How do I use operators?
An operator allows you to specifying multiple values in a field. There are three operators:
1. The asterisk ( ) : This operator specifies all possible values for a field. For example,
an asterisk in the hour time field would be equivalent to every hour or an asterisk in the
month field would be equivalent to every month.
2. The comma (): This operator specifies a list of values, for example: "1,5,10,15,20,
25".
8/10/2019 Mysql and Sqlite Commands
14/47
3. The dash (-): This operator specifies a range of values, for example: "5-15" days ,
which is equivalent to typing "5,6,7,8,9,....,13,14,15" using the comma operator.
4. The separator (/): This operator specifies a step value, for example: "0-23/" can be
used in the hours field to specify command execution every other hour. Steps are also
permitted after an asterisk, so if you want to say every two hours, just use */2.
How do I disable email output?By default the output of a command or a script (if any produced), will be email to your
local email account. To stop receiving email output from crontab you need to append
>/dev/null 2>&1. For example:
0 3 * * * /root/backup.sh >/dev/null 2>&1
To mail output to particular email account let us say vivek@nixcraft.in you need to define
MAILTO variable as follows:
MAILTO="vivek@nixcraft.in"
0 3 * * * /root/backup.sh >/dev/null 2>&1
See "Disable The Mail Alert By Crontab Command" for more information.
Task: List all your cron jobsType the following command:
# crontab -l
# crontab -u username -l
To remove or erase all crontab jobs use the following command:
# Delete the current cron jobs #
crontab -r
## Delete job for specific user. Must be run as root user ##crontab -r -u username
http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/8/10/2019 Mysql and Sqlite Commands
15/47
changing directory
list of long files
list of files
list in long formatall files including those which begin with dot
list the inode number in the first column
recursively list all directories and subdirectories
Sort files by access time.
with time
Shows the names of directories and not their contents
Indicates human readable. This mentions file sizes in kilobytes, megabytes, or
gigabytes, instead of just bytes, which is the default setting. Use this option with the
l option only.
Sorts files by file size. This option is useful only when used together with the option l
with count
for giving premissions
To Change working directory.
Syntax : cd >
cd
Copy files and directories
for secure copy
Rename SOURCE to DEST, or move SOURCE to DIRECTORY/fileSyntax : mv >
Displays manual entries online.(To get help of the commands.)
Syantax : man
To search any word in man page use / and string name.
n for checking next search and N for previous search.
To quit press :q.
8/10/2019 Mysql and Sqlite Commands
16/47
Clears the terminal screen
Terminate the process, returning returnCode to the system as the exit status. If
returnCode isn't specified then it defaults to 0.
Counts the number of lines, words, bytes, or characters in a file.
Syntax : wc [ -c | -m ] [ -l ] [ -w ] [ File ... ]
To see the current working directory
It shows who is logged in the same machine
Determine file type.
Creates a new file with zero size or update the timestamp of an existing file.
Removes (unlinks) files or directories
Syntax : rm
Options can be
-i interactively asks for confirming the deletion of files. It is useful in
avoiding accidental erasure of the file
-r option provides a convenient way to erase a directory even if it is not
empty
-f option will forcefully remove a file to which we dont have a writepermission.
Vi IMproved, a programmers text editor
#vi Bachi.txt
Then you can enter Insert key or i. Now you are able to type text into that file(Bachi.txt).
Once it finish press Esc button and type : and type wq .
Now check with ls l command
Concatenate files and print on the standard output
Change file owner and group
Make links between files
8/10/2019 Mysql and Sqlite Commands
17/47
Print system informationTo find Physiacl RAM(Linux)
To find Physiacl RAM(AIX)
To find the Number of CPUs(Linux)
To find the Number of CPUs(AIX)
Report file system disk space usage.
Syntax: df *OPTION+... *FILE+
Estimate file space usage.
Show listing of last logged in users.
Displays or sets the date or time.
Syntax : date +[option]
e time,H-hour,M-minuts
zip, zipcloak, zipnote, zipsplit - package and compress (archive) files
e.g.: zip -9 -r BhaskarReddy.zip BhaskarReddy
zip -rm Bhaskar.zip BhaskarReddy
Unzip - list, test and extract compressed files in a ZIP archive.
e.g. : unzip BhaskarReddy.zip
Creates a new user account
Changes a user's password
Note: # Indicates root user
& Indicates normal user
create a new group
Changes user attributes
8/10/2019 Mysql and Sqlite Commands
18/47
Displays group membership.
Removes a user account.
Switches the user between users and root. (Changes the user ID associated with a session.)
Displays the system identifications of a specified user.
Displays a compact list of the users currently logged on the system.
Note: See first it displays only one user name called root, afther that I logged with bhaskar user in
other terminal, then it shows two users.Opens a line of communication to send messages to other users on the system in real time.
Syantax: # write
Writes a message to all users that are logged in.
Syntax
wall [ -a ] [ -g Group ][ Message ]
for secure copy
move
view
check processers
kill the processescheck the space
for size of that file
making director
inserting and save that file
for moving to last line after view
remove the file
remove all files
remove for ever
to show the date
for secure copy
for tar that file
count of lines,words,charecters in that file
count of lines in that file
count of charecters in that file
count of words in that file
Display numer of .
8/10/2019 Mysql and Sqlite Commands
19/47
Change permission of the file
777 ----> Change permission of the file, make it to executable by all(Owner, Group and Others).
400 ----> Change the permission of the file only Owner can read
for connecting to database
for viewing the databses
for using that databse
for viewing the tables
for knowing the count
for connecting to database
for viewing the tables
for knowing the count
for delete the contain that table
update
taking data from table as a csv file
view/creat file
inserting and save that file
giving premissions
run the sheel script
for output
8/10/2019 Mysql and Sqlite Commands
20/47
giving cronjob
website:http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
8/10/2019 Mysql and Sqlite Commands
21/47
8/10/2019 Mysql and Sqlite Commands
22/47
8/10/2019 Mysql and Sqlite Commands
23/47
8/10/2019 Mysql and Sqlite Commands
24/47
8/10/2019 Mysql and Sqlite Commands
25/47
build and release
8/10/2019 Mysql and Sqlite Commands
26/47
8/10/2019 Mysql and Sqlite Commands
27/47
8/10/2019 Mysql and Sqlite Commands
28/47
8/10/2019 Mysql and Sqlite Commands
29/47
1)Permissions
2) Number of links
3)Owner
4)Group Owner
5)Size of the File in Bytes
6)Date and Time of created
7)File name
8/10/2019 Mysql and Sqlite Commands
30/47
8/10/2019 Mysql and Sqlite Commands
31/47
8/10/2019 Mysql and Sqlite Commands
32/47
8/10/2019 Mysql and Sqlite Commands
33/47
8/10/2019 Mysql and Sqlite Commands
34/47
8/10/2019 Mysql and Sqlite Commands
35/47
8/10/2019 Mysql and Sqlite Commands
36/47
8/10/2019 Mysql and Sqlite Commands
37/47
1File Management
Name
ls
pwd
cd
filecp
cp
mv
mv
rm
rm
less
mkdir
quota
2Tar Archives
Name
tar
tar
gzip
gunzip
tar
tar
3Getting Help
Name
man
info
apropos
whatis
4User Accounts
Namewho
who am i
finger
groups
whois
last
8/10/2019 Mysql and Sqlite Commands
38/47
5Documents
Name
wc
ispell
head
tail
6Processes
Name
ps
ps
kill
top
8/10/2019 Mysql and Sqlite Commands
39/47
Purpose
Lists files in the current directory
Prints the current working directory
Changes the current directory
Describes the contents of a fileCopies files
Copies directories
Moves files
Renames files
Removes (deletes) files
Removes (deletes) directories
Views the contents of files
Makes new directories
Tells you how much disk quota you are using and how much you have left
Purpose
Bundles many files together into one file called a tarfile
Extracts files from a tarfile
Compresses files to save space
Uncompresses files
Stores many files into a tarfile and compresses them
Extracts compressed tarfiles
Purpose
Displays manuals for programs
Displays info-pages for programs, an alternative manual system
Searches for a command by keyword
Gives a summary of a program
PurposeTells you who's logged into the system
Tells you about yourself
Prints out information about user accounts
Lists what groups a user belongs to
Searches for Users by surname
Shows the last N logins
8/10/2019 Mysql and Sqlite Commands
40/47
Purpose
Counts words in a document
Spell checks a document
Displays the first few lines of a file
Displays the last few lines of a file
Purpose
lists all the processes running for that login
lists all processes running for all logins of a user
stops a process from running
Lists the largest processes running
8/10/2019 Mysql and Sqlite Commands
41/47
Example
ls
pwd
cd foo/
file foocp a b
cp -r foo bar
mv a ./foo/
mv a b
rm foo
rm -r foo/
less foo
mkdir foo
quota -v
Example
tar -cf files.tar foo bar baz
tar -xf files.tar
gzip foo
gzunzip foo.gz
tar -czf files.tar.gz foo bar baz
tar -xzf files.tar.gz
Example
man ls
info ls
apropos keyword
whatis ls
Examplewho
who am i
finger -l username
groups username
whois smith
last
8/10/2019 Mysql and Sqlite Commands
42/47
Example
wc foo
ispell foo
head foo
tail foo
Example
ps
ps -U username
kill 17829
top -n 10
8/10/2019 Mysql and Sqlite Commands
43/47
Explanation
changes to the directory foo
prints a message about what type of file foo iscreates a copy of file `a' called `b'
Copies the directory foo to the directory bar, copies all files and directories inside it too.
moves file `a' into the directory foo
moves the file `a' to be called `b'
deletes the file called foo
deletes the directory called foo
opens the file foo in less. Use space for next page, bfor back a page, qto quit.
creates a new directory inside the current one called foo
Explanation
Creates a tarfile called files.tar that contains the files foo, bar and baz.
Extracts all the files from files.tar into the current directory.
Zip's the contents of the file foo, removing the original file and replacing it with a file called foo.gz.
Unzips the file foo.gz, renaming the uncompressed version foo and removing the original zipped file.
Creates a tarfile called files.tar.gz and stores the files foo, bar and baz in it. It also passes the tarfile throu
Uncompresses files.tar.gz to files.tar then extracts all the files from it into the current directory.
Explanation
shows the manual for the ls command
shows the info page
Displays a list of documentation relating to keyword for example networking or files.
Gives a description of what the ls program is for.
Explanation
prints out information about the user called username.
Prints out the group names that the user username belongs to.
prints out the usernames and real-names of all users who's surname is smith
8/10/2019 Mysql and Sqlite Commands
44/47
Explanation
outputs three numbers relating to file foo, number of lines, number of words and number of
characters.
spell checks the document called foo, creates a backup file called foo.bak first.
Prints out the first 10 lines of the file called foo.
Prints out the last 10 lines of the file foo.
Explanation
displays all the processes of user username, this can be your own username.
Kills the process with the PID 17829. Process Identification Numbers are found with ps.
Prints out the top 10 processes and a lot of information about the system.
8/10/2019 Mysql and Sqlite Commands
45/47
8/10/2019 Mysql and Sqlite Commands
46/47
Sno
1
2
8/10/2019 Mysql and Sqlite Commands
47/47
Commands
For copying/print same pattern records in file
Command
awk '/PATTERN/ {for(i=1; i "same.csv"}' member_information_2014-03-10.csv
awk -F"\t" '{ print$36,$37 }' member_information_2014-03-10.csv > date.csv
45 22 * * * /data/Installations/Enliven/Cronjobs/CollectionFiles.sh