Showing posts with label Unix Commands. Show all posts
Showing posts with label Unix Commands. Show all posts

Monday 12 May 2014

Unix Commands - All important commands which every developer should know

Unix Commands - All important commands which every developer should know

List all files and directory
$ ls

List all files and directory with their detail like permission, owner and created date
$ ls 
$ ls -l

List all files and directory with more option (when list is more than 1 page)
$ ls -l | more

Remove directory
$ rmdir dirname

Remove a file
$ rm filename

Remove a file without "confirmation"
$ rm -f filename

Remove a directory
$ rmdir filename

Copy source to destination
$ cp sourceFile destinationFile

Move a file from one location to another
$ mv source destination

Online manual (help) about command
$ man ls

Find a text in file and return that line
$ grep searchText fileName

Change the File/Directory Permission
$ chmod 644 fileOrDir

List the preprocessor
$ ps

Find text in List of processor
$ ps | grep STIME

Kill the process
$ kill 45555

Zip a file
$ gzip filename 

Unzip a file
$ ungzip filename.zip

List who is logged on your machine
$ who

List who is on the computer in the lab
$ finger

List of History you have done recently
$ history

Print the current Date
$ date

print the calendar for September 2000
$ cal 09 2013

See how much free disk space
$ df

Set the Alias for command
$ alias newc="ls -l";

Print system usage and top resource hogs
$ top

Logout from the putty/console
$ logout
$ exit

Progressively dump a file to the screen: ENTER = one line down SPACEBAR = page down  q=quit$ more filename

Show the firest few lines of a file
$ head filename
$ head -n  filename

Show the last few lines of a file
$ tail filename
$ tail -n  filename

Search the text and store the output in file
$ grep string filename > newfile
$ grep string filename >> existfile

Finds all the files named aaa.txt in the current directory or any subdirectory tree.
$ find . -name aaa.txt

Open a file in edit mode
$ vi filename

Open file in vi editor and go to line no 101 instant
$ vi +101 filename

Show the line number in front of each line in vi editor
:set number

Go to particular line number in vi editor
:14
:100
:5

Search text "searchme" in the vi editor
:/searchme
to search next press "n" and for previous "shift+n"

Come out from vi editor
"shift+:" and press "q" and then press "enter key"

Edit modes (These keys enter editing modes and type in the text of your document.)
i  Insert before current cursor position
I  Insert at beginning of current line
a  Insert (append) after current cursor position
A  Append to end of line
Open and put text in a new line below current line
O  Open and put text in a new line above current line
r  Replace 1 character
R  Replace mode
<ESC> Terminate insertion or overwrite mode


Deletion of text
x   Delete single character
dd  Delete current line and put in buffer
ndd Delete n lines (n is a number) and put them in buffer
J   Attaches the next line to the end of the current line (deletes carriage return).

Cut and paste
yy Yank current line into buffer
nyy Yank n lines into buffer
p  Put the contents of the buffer after the current line
P  Put the contents of the buffer before the current line

Cursor positioning  (symbol (^ )before a letter means that the <Ctrl> key should be held down while the letter key is pressed)
^d  Page down
^u  Page up
^f   move forward one screen
^b  move backward one screen
^g  Display current line number
:n   Position cursor at line n
:$  Position cursor at end of file


Give on which server you are on
$ uname
Linux

Give your hostname
$ uname -n;
$ hostname

Kill your task
$ kill 1202255

Command displays active processes
$ ps


Display today's CPU activity
$ sar

Change the File's timing (created, access and modification time);
$ touch file.txt
If file is not exist, If will create the file

set  the access and modify timestamp
$ touch -t 06151330 f1.c;

Get file stats
$ stat file.txt

Change the owner of file/folder
$ chown vivek demo.txt
Owner of demo.text is set to vivek

Change the owner & Group of file/folder
$ chown vivek:arun demo.txt
Owner of demo.text is set to vivek
Group of demo.text is set to arun

Change the group of file/folder
$chown :ftp demo.txt
Group of demo.text is set to ftp

Change the owner of folder
$chown root /folder
Owner of /folder set to root

Change the owner of folder and its subfolder
$chown -R root /folder
Owner of /folder and its sub folder, set to root

List of user
$ w
$ who

Number of files in folder
ls -l | wc -l

Number of files in folder including dot and hidden files
ls -lA | wc -l

List the files sort by date
ls -ltr

Execute URL in Lynx with credentials
lynx http://example.com/action.php -accept_all_cookies -auth=username:'password'

List the crontab in your application
$ crontab -l

Edit the crontab timings
$ crontab -e

Total files in Directory
ls -1 | wc -l

Get the Files size in MB (Mega bytes) in unix command
$ ls -lash

Show the list of files committed in revision 570 of SVN
svn log -r 570 -v

Show the list of previous 5 users who have commit the file in SVN
svn log -l 5

Show the previous 5 logs of AjaxController.php
svn log -l 5 AjaxController.php

Show the previous all logs of AjaxController.php
svn log AjaxController.php




Thursday 6 March 2014

Linux Access logs - List of Columns - Simple commands to view Server Logs

Linux Access logs - List of Columns - Simple commands to view Server Logs

When we run our website in Linux server, we must know about the linux access logs and error logs. Because with use of access log we get to know who is accessing our website and with use of error logs we get to know what types of error are coming in our website while running.

So, Access Logs/Error Logs are very important thing not for server admin but also for developer. Because sometimes website is very well developed by developer but due to server error, website is not performing well. If website is not working fine then it can effect the your users and directly it will decrease the annual income.

Get basic understanding of Server/Access logs. And if there is any issue with your server logs then get fixed ASAP. 

Following are the List of columns which are in Access Log

  • Remote Address – IP from which request was made
  • Remote User – Will bank for public pages
  • Date Time – timestamp as per server timezone
  • URL – HTTP request with  GET/POST/PUT/DELETE etc + Arguments + HTTP/HTTPS
  • Status – HTTP response code 
  • Response Size – size of server response in bytes
  • HTTP REFERRAL URL – Referral URL (if present)
  • User Agent – User agent as seen by server

Access log file location
cd /var/logs

Get the First column of log file
cat access.log | cut -d '"' -f1

Get the First colum of log file
cawk '{print $1}' cat access.log

Tuesday 31 December 2013

SVN Important Commands

SVN is a software version and revision control system distributed as free software under the Apache. Many companies like Apache Software Foundation, Free Pascal, FreeBSD, GCC, Mono, SourceForge and Google also provides Subversion hosting for their free software projects.


Following are SVN Important Commands


Get the New Checkout, It will get from root folder
$ svn checkout [URL]  

Get the New Checkout, It will get from testfolder
$ svn checkout [URL] [testfolder]  

Get the entire update
$ svn update           

Get the update for testfile.php and testfile.php
$ svn update testfile.php, testfile1.php   

Revert the testfile.php
$ svn update testfile.php

Commit with the Message
$ svn commit - m "message here"

Commit the particular file with Message 
$ svn commit - m "message here" testfile.php

Add a new file
$ svn add testFile1.php
$ svn commit -m "test message" testFile1.php

Remove the existing file
$ svn remove -m "test message" testFile1.php
$ svn commit -m "test message" testFile1.php

SVN Info
$ svn info

Get Help on commit command
$ svn help commit

Get log for a file
$ svn log testFile.php

Get log for particular revisionNumber
$ svn log -r 825

Commit a modification to the file test1.php with the commit message in a file named msg
$ svn commit -F msg test1.php





Monday 30 December 2013

Linux Yum Command Examples – Install, Uninstall, Update Packages, List and Search

Linux Yum Command Examples

Full form of YUM is Yellowdog Updater Modified. It is default package manager, mainly use for installation work.

Synopsis
yum [options] [command] [package]  
yum -y install php
Here
  -Y is option (-y=yes)
  install is command
  php is package

 Install PHP
$ yum install php

Update PHP
yum update php

Remove PHP
$ yum remove  php

Search for a package to be installed
$ yum search php

Show information about package
$ yum info php

Show all available package
$ yum list | less 

Show all installed package
$ yum list installed
$ yum list installed | less    

Install a new software group
$ yum groupinstall 'DNS Server'

Remove new software group
$yum groupremove 'DNS Server'  

Update software group
$ yum groupupdate 'DNS Server' 

List all software group
$ yum grouplist


Thursday 8 August 2013

GitHub in window 7 | GitHub Commands in Linux

GitHub in window 7 | GitHub Commands in Linux

Setup the GitHub in window machine. GitHub is most widely used repositary in development. Get to know commands to work with github.

Create repository in github
Login to your github account, If not have account please register first.
After login to your github account, Click on "Create new Repo" Icon @top right in header to create new repo.
Add "Repository name" and Description of your new repository.
Public Repository is free and private is paid. so let start with free(public repo)
After clicking on "Create repository", your repository will create.
Save the URL of your repo, It will be similar to "https://github.com/poonamc/Ansh"

Download the console for github
ate/delete files in repo
After download, Install it and Run the "Git Bash"

All command must be executed in sample folder.

Add a file in github through console(First Time)
Open "Git Bash"
Go to folder/directory where you want to keep your files @local system using "Cd" command.
Create a folder and go inside that folder
add a sample file in that folder from UI
execute following commands one by one and add your github username/password they they prompt (In Last)

git init
git add test.php
git config --global user.name "Arun"
git config --global user.name "arun@no-spam.ws"
git commit -m "test file"
git remote add origin https://github.com/poonamc/Ansh.git
git push -u origin master


Add a new file in github
add a new file in folder (suppose file name is "arun1.php")
Execute following commands one by one
git add arun1.php
git commit -m "test file arun1.php"
git push -u origin master


Update a file in the github
Change one file and save
Execute the following commands one by one
git add *
git commit -m "updated file"
git push -u origin master


Delete a file
git rm arun1.php
git commit -m "deleted file"
git push -u origin master