Linux Tips & Tricks

Tuesday, June 18, 2013

UNIX/Linux script to set or update the password for multiple users

›
Example: Sample users name: dummy1, dummy2, dummy3, dummy4 and dummy5 for counter in {1..5}; do echo "dummy$counter" | passwd...
22 comments:

UNIX/Linux Shell Script to delete multiple users

›
Example 1: To delete the users: dummy1, dummy2, dummy3, dummy4 and dummy5 for  counter in {1..5}; do userdel dummy$counter; done It ...
3 comments:

UNIX/Linux Shell script to create multiple users

›
Example 1: NOTE:   {1..5} syntax will not work in certain shell. But it will work definitely in bash. Example 2: cat > u...
2 comments:
Monday, June 10, 2013

How to grep recursively in Solaris?

›
In Solaris, Solaris grep will not provide recursive option -r to search a pattern recursively. But solaris provides another command called g...
5 comments:
Thursday, October 18, 2012

How to find the current shell in UNIX Solaris Linux?

›
This method works perfectly in any shell. NOTE: $$ holds the process id of current shell. [penguin@cheetah:/home/penguin]#ps | grep -i `...
5 comments:
Monday, October 1, 2012

What is meant by Pipe and Filter in Unix or Linux?

›
PIPE: Pipe is a way of passing data from standard output of one process to standard input of another process. Filter: It is a program...
Friday, September 28, 2012

How to list only hidden files in UNIX?

›
ls -1A | grep '^\.' Eg: [vjsujay@cheetah:/home/vjsujay]#ls -1A | grep '^\.' .profile .recently-used .sh_history .so...
2 comments:
Thursday, September 27, 2012

How to update and replace files in a tar archive?

›
Question 1: How to update an existing tarball contents with newfile(s)? Answer: We have to use the function ‘u’ to update newfile(s) t...
3 comments:

How to pass large number of files as an argument for tar archive creation?

›
Question: How to pass large number of files as an argument for tar archive creation? Answer: Using the option ‘I’   From Solaris M...

How to extract the desired file/directory from a tar archive in Unix or Linux or Solaris

›
Question: To extract the desired file/directory from a tarball Answer:   Pass the desired file/directory as an extra argument to the ...
1 comment:

How to find the default shell in UNIX or Linux or Solaris

›
Question: Default shell of the logged in User Answer: There are many ways to find the default shell. a)       By checking the la...
3 comments:
Wednesday, September 26, 2012

What is the flow in UNIX or UNIX like operating system for commands execution?

›
As soon as we press the enter key after the command, the below sequence will be followed. 1.  Check alias and then execute the command(she...
Friday, September 14, 2012

Why we shouldn't give 777 to any directory in UNIX or LINUX?

›
Giving 777 to any directory in UNIX or Linux or UNIX based Operating System is a potential security risk. Because if a directory contains 77...
Tuesday, September 11, 2012

How to find RAM size, CPU speed and CPU count in Solaris Sparc System

›
1.)Question: How to find the number of CPU, CPU Speed and RAM size? Ans: prtdiag Command Name: prtdiag Purp ose: To display the...
1 comment:
Sunday, April 10, 2011

How to find empty files in UNIX?

›
There are multiple ways to find whether a file is empty or not. Please see few examples below, volcano@volcano-laptop:~/shellscript$ ls -l...
4 comments:
Saturday, April 2, 2011

How to remove empty lines from a file in UNIX or Linx

›
volcano@volcano-laptop:~/shellscript/empty$ cat testempty hi first line above line is empty hi dude above line is empty volcano@volca...
16 comments:

How to remove CONTROL-M characters in UNIX or Linux

›
Control-m characters will get appended to a file when a file is transferred from windows to UNIX machine. There are multiple ways it can be ...
165 comments:
Saturday, December 4, 2010

How to remove files starting with - minus in the filename

›
There might be several ways to remove files starting with first character as - minus. But i am providing 3 solutions below. 1. $ rm ./-filen...
7 comments:
Monday, January 25, 2010

Difference between Unix Internal & External Commands

›
Internal Unix commands are built with the shell and hence it will run in the same shell. eg: cd External Unix commands will start a new shel...
2 comments:
Saturday, January 23, 2010

How to run a unix shell script from any directory

›
To run a script from anywhere inside UNIX directory, you need to include the script absolute directory in the PATH variable. After that with...
1 comment:
Saturday, October 10, 2009

Order of execution for /etc/profile .bash_profile .bash_login .profile /etc/bash.bashrc .bashrc

›
If interactive login-shell or non-interactive login shell with --Login option is started, it will start reading & executing in the order...
2 comments:

Difference between .profile and .bashrc

›
.profile will be read, whenever login-shell is started .bashrc will be read, whenever new interactive shell(not a login shell) is started
Monday, August 24, 2009

How to compress multiple files using tar and gzip

›
1. Put all the required filenames in a file 2. tar all the files 3. gzip the tar file eg: vjsujay@gmail.com$ ls *.html > filelist vjsuja...
1 comment:
Monday, July 20, 2009

To display only the user directories in Unix or Linux

›
vjsujay@home$ ls -lA "pipeline symbol" grep '^d' drwxr-s--- 2 n0160429 ccipadm 512 Jul 21 00:17 .temp drwxr-s--- 2 n01604...
1 comment:
Saturday, July 18, 2009

Difference between single square and double square brackets in conditional check in shell scripting

›
1. [ conditional check ] -> Variables used in the conditional check should have value, otherwise exception will be thrown during the exec...
Friday, July 17, 2009

Different type of Command Substitution in Shell Scripting

›
In two ways we can do the command substitution. 1.) Using backquote: `` 2. Using dollar sign and parenthesis: $() eg: vjsujay@home $ echo ...
Friday, March 13, 2009

To find last day of any month & year using unix command

›
2 comments:
Wednesday, June 11, 2008

How to keep track of your Unix/Linux command execution and its output

›
By using "script" command, you can keep track of Executed Commands and its output. Definition: The script command will keep a tran...
6 comments:

Different ways of running a Shell Script

›
1. Executing the Shell Script file as a command in the Shell Prompt vjsujay@linuxdemon$sample.sh 2. Executing the Shell Script file using s...
1 comment:
Wednesday, April 16, 2008

Copying longfilenames without retyping

›
$ ls -l thisismytestfile -rw-r--r-- 1 Ajay None 13 Apr 17 03:22 thisismytestfile Ajay@intel ~ $ cp thisismytestfile{,.bk} Ajay@intel ~ $ ls ...
1 comment:
Monday, June 25, 2007

How to Truncate a file in Unix/Linux

›
:>filename If the filename already exists,the file will be truncated to ZERO byte file else a new file with ZERO byte will be created. Ex...
1 comment:
Tuesday, May 15, 2007

Commenting Multiple lines in a shell script

›
By using anonymous here document, we can comment multiple lines in a shell script for debugging purposes. eg: : echo "Not in the Scope ...
2 comments:
Tuesday, May 8, 2007

Length of a string in Linux

›
The command syntax is ${#string} Example: linuxdemon$lindem="linux demon" linuxdemon$echo ${#lindem} 11 Explanation: 1.Assigning t...
1 comment:
Wednesday, April 18, 2007

FTP Automation using Shell script

›
I am going to give the code in shell script for ftp automation. ftp -n servername/serverIP user giveusername givepassword Any ftp comma...
1 comment:
Monday, April 16, 2007

How to mount WIN partition in Linux?

›
Temporary Mounting: After the reboot of your system, you need to again execute the mount command to mount the win partition in Linux. 1.You...

How to rename group of files?

›
I am giving a simple shell script, for renaming a group of files in the current directory.In the script, i have renamed all .jsk files to .t...
4 comments:
Home
View web version
Powered by Blogger.