Unix has a great oppertunites in IT fiels. Be it
Development , Support ot Tech Support.
use a perl one liner like this
perl -e '$var="hi pravin how are you";@arr=split("
",$var);foreach $wrd(@arr){print ucfirst($wrd)." ";}'
The file "test" contains "hi pravin how are you?".
sed -e "s/^[a-z]/U&/" -e "s/[[:space:]][a-z]/ U&/g" test
shebang is also called as hashbang.This basically used for
interpretation.This should be the 1st line of any shell
script which indicate the script to run in specified shell.
For ex. If the 1st line of a shell script is #!/bin/ksh
then the program has to run under korn shell.If you do not
specified any shebang then it will run under default shell.
a shebang (also called a hashbang, hashpling, or pound
bang) refers to the characters "#!. The shebang is looked
for and used when a script is invoked directly.
Because the "#" character is often used as the comment
marker in scripting languages, the contents of the shebang
line will be automatically ignored by the interpreter
itself; the shebang line only exists to specify the correct
interpreter to be used.
No way one can get the password of other user even if root
also can not get the password unless untill there is an
readble entry in /etc/passwd file. But for the super user,
it doesn't need to know the user's passwrod to access his
docs.
No, No one can't know the passwd because it is stored in in
/etc/shadow file as MD5 Hash ,
and link at /etc/passwd.
We can convert Value(passwd) to Hash but not Hash to
value(passwd)
Super user is also not able to retrive passwd......
By Choyal
cat filename | uniq -u | sort -n
#!/bin/csh
# Here tr -s ' ' replaces all multiple ' ' with single ' '
# next pipe the above stream to replace each ' ' with 'n'
# next pipe the above stream to get a sorted list of words
# then pipe the unique words to outfile
tr -s ' ' < $1 | tr ' ' 'n' | sort | uniq > $1.out
it shows the path for the interpreter
#! indicates from where the path of the interpretor should
be considered and also directs that the contents of the
file which will be following will be executed under the
guidelines of this interpretor being used.
In Unix, to know the current date and time, the command is
date.
$date -u +%r -->02:26:38 PM
$ date -u +%T -->14:26:48
select E.name from department D, emp E
where D.name = E.dname
and E.dname <> 'A'
and E.sal > (select min(E.sal) from department A, emp E
where A.name = E.dname
And E.dname = 'A')
Don't mind my answer is lengthy....
Let file name be employee
name, rollno., salary, grade
cut each of records in each field to temp files as follows:
-----------------------------------------------------------
cut -f1 employee > /sm.tmp.$$
cut -f2 employee > /sn.tmp.$$
cut -f3 employee > /so.tmp.$$
cut -f4 employee > /sp.tmp.$$
Paste them as required in to another file as follows
----------------------------------------------------
paste /sn.tmp.$$ /sm.tmp.$$
paste /sn.tmp.$$ /so.tmp.$$
paste /sn.tmp.$$ /sp.tmp.$$
sh File_Name.sh
then press enter
If the path variable does not contain ur current
directory,then you can execute the script by giving
$./scriptname
If you include your current directory in path variable then
$scriptname
or
If u want to invoke new shell
$ ksh scriptname
create a variable for your query like
sql1='select empid,empname,.... from emp;' in your script
then call sqlplus in your shell script as
slplus user/password@sql1
you can redirect the output or format it as you like.
you can pass userid pwd as parameters as arguments to your
shell script and use them as parameters $1 and $2. you can
check if all the parameters are given with Usage [$# eq. 2 ]
etc.
sqlplus username/userpassword@oracle<<eof
>select * from emp;
>select empno,ename,sal,deptno;
........what ever commands u wanna execute of sql u can
write here
>hit ctrl+d
these are called as here documents
If we would knew the structure of LOOK_UP.dat (like the
structure of file is mentioned) then the script could be
more precisely written.
6 levels is correct,XIn Red Hat Linux, the default boot
level is 3, unless booting into an X Windows login, the
default boot level then is 5.
Runlevels Generic mode
0 halt
1 Single user mode
2 Multiuser, without Networking
3 Full multiuser mode
4 unused
5 X11
6 reboot
You can view the settings of default runlevel
in /etc/inittab. The command /sbin/chkconfig --list is used
to display a list of all runlevels and services.
There are 6 levels
init 0 :- Shutdown (halts)
init 1 :- Single user mode or emergency mode, that means no network no multitasking is present in this level, only root user has access in this run level.
init 2 :- NO network but multitasking is present
init 3 :- Network and multitasking is present but without GUI
init 4 :- Unused level.
init 5 :- Boot up a full multi user system and to automatically start X-Wnindows
init 6 :- System restart in this level.
for file in `ls` ; do NEW=`echo $file | sed 's/.txt/.my/g'`
; mv $file $NEW ; done
for i in `find . -name "*.txt"`
> do
> mv $i ${i%.txt}.my
> done
how many shell supported by your system
check the file /etc/shells
> ps -a |grep -E 'sh$' |wc -l
-a is for to list process of all users
-E extended grep to filter the shells (since they end with sh like bash, tcsh, ksh, sh
-$ to match only at the end of the line where the process is printed
paste -d"n" file1 file2 > file3
Unix utility sed can be used serve the purpose
Assuming file1.txt and file2.txt are two input files and
file3.txt is the third file.
Contents of the file1.txt
line 1
line 2
line 3
Contents of the file2.txt
LINE 1
LINE 2
LINE 3
After executing below mentioned command
sed -n -e '{
> R file2.txt
> p
> }' file1.txt > file3.txt
The third file file3.txt will be
line 1
LINE 1
line 2
LINE 2
line 3
LINE 3
#!/bin/sh
for i in {1..10)
do
echo "creating user"$i;
useradd user$i;
done
to list the created users.
cat /etc/passwd
My dear friends,
you have used 'useradd' command in the script through which we can only add the user name. But for adding password you should use 'passwd' command because password is also mandatory.
#!/bin/bash
/bin/ftp -inv ip_address_of_target_station<<ENDFTP
user ftpusername ftpuserpassword
cd folder_on_target
bin
lcd folder_on_local
put filename.txt
bye
ENDFTP
# Alternatively some ftp packages let you put a script in
$HOME/.netrc
if [ $# -ne 3 ]
then
echo "$0: number1 number2 number3 are not given" >&2
exit 1
fi
if [ $1 -eq $2 ] && [ $1 -eq $3 ]
then
echo "All the three numbers are equal"
elif [ $1 -eq $2 ] && [ $1 -gt $3 ]
then
echo "$1 and $2 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $1 -eq $3 ] && [ $1 -gt $2 ]
then
echo "$1 and $3 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $2 -eq $3 ] && [ $2 -gt $1 ]
then
echo "$2 and $3 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $1 -eq $2 ] && [ $1 -lt $3 ]
then
echo "$3 is largest number among $1 $2 and $3"
elif [ $1 -eq $3 ] && [ $1 -lt $2 ]
then
echo "$2 is largest number among $1 $2 and $3"
elif [ $2 -eq $3 ] && [ $2 -lt $1 ]
then
echo "$1 is largest number among $1 $2 and $3"
elif [ $1 -gt $2 ] && [ $1 -gt $3 ]
then
echo "$1 is largest number among $1 $2 and $3"
elif [ $2 -gt $1 ] && [ $2 -gt $3 ]
then
echo "$2 is largest number among $1 $2 and $3"
elif [ $3 -gt $1 ] && [ $3 -gt $2 ]
then
echo "$3 is largest number among $1 $2 and $3"
else
echo "I can not figure out which number is
largest"
fi
mr imran/vipul
when i run this script it always say number not given
what is the reason and how would this ask for the those 3 numbers to be sorted ??
#include<stdio.h>
#include<stddef.h>
#include<dirent.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<time.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
char in[100],st[100],*ch,*ch1,c,buff[512];
DIR *dp;
int i;
struct dirent *ep;
struct stat sb;
char mon[100];
dp=opendir("./");
if(dp!=NULL)
{
while(ep=readdir(dp))
{
if(stat(ep->d_name,&sb)==-1)
{
perror("stat");
exit(EXIT_SUCCESS);
}
strcpy(mon,ctime(&sb.st_ctime));
ch=strtok(mon," ");
ch=strtok(NULL,",");
ch1=strtok(ch," ");
if((strcmp(ch1,argv[1]))==0)
{
printf("%s tt %s",ep->d_name,ctime(&sb.st_ctime));
}
}
(void)closedir(dp);
}
return 0;
}
Create time is not kept in the inode. Times for Access,
Modify, and Change is all you get.
The Unix category on takluu.com is designed for IT professionals and developers preparing for interviews that require a strong understanding of Unix operating systems. Unix has been the backbone of many enterprise systems due to its stability, security, and multitasking capabilities.
This section covers key topics such as Unix file system architecture, shell scripting, process management, file permissions, user management, and networking commands. You will also learn about vi editor, cron jobs, package management, and system monitoring tools.
Interview questions often assess your proficiency in writing shell scripts, automating tasks, troubleshooting system issues, and managing user permissions. Candidates may be tested on commands like grep, awk, sed, find, and piping techniques, as well as understanding system boot processes and kernel basics.
Roles such as Unix Administrator, DevOps Engineer, System Engineer, and Backend Developer often require expertise in Unix environments. This category also includes best practices for security hardening, backup strategies, and performance tuning in Unix systems.
At Takluu, we offer detailed tutorials, practical exercises, and interview question sets that will help you build confidence and excel in your Unix-related interviews.
Whether you’re a beginner or looking to deepen your Unix skills, this category equips you with comprehensive knowledge to manage Unix systems efficiently and advance your career.