Solved

Unix 14 questions

Posted on 2015-02-21
9
85 Views
Last Modified: 2016-04-04
Dear Experts,

I attended an Unix Oracle interview last week and i managed to answer the questions with the help of knowledge which i have gained from you/EE.

But i would like to know various method of doing the same . So request you to spend some time and answer the queries below .

1.What is difference between softlink and hardlink?
2.What is file system in Unix?
3.What does #! (shebang) tells in the script ?
4.What is nohup?
5.How to pass a variable var1=TEST from parent script 1.sh to child script 2.sh?
6.How to find files which was modified in last 30 days?
7.How to find files which was not modified in last 30 days?
8.What is the difference between ONICE and ONHOLD in Autosys?
9.How to print the 50th line in a file?
10.Difference between grep and find?
11.Difference between du and df?
12.How to terminate a process in shell?
13.How to read/list a compressed file?
14.How to add a line "TEXT" in the 1st and last line of the file?


Thanks,
Magento
0
Comment
Question by:magento
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40623667
Consulting the unix man pages is a good method.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40624596
A basic Linux course will help you on the way.
0
 
LVL 5

Author Comment

by:magento
ID: 40624994
This is what i have tried.

1.What is difference between softlink and hardlink?
Softlink is kind of shortcut and its share the same inode whereas hardlink doesnt have same inode.
softlink: ln -s shortcut originalpath
hardlink: ln target original
2.What is file system in Unix?
/etc , /dev , /bin , /var/log etc are file systems in Unix.
3.What does #! (shebang) tells in the script ?
Which Shell the script going to use . eg./bin/bash or /bin/ksh
4.What is nohup?
If i use nohup script.sh , even when the terminal/session exits the script will run .
5.How to pass a variable var1=TEST from parent script 1.sh to child script 2.sh?
export var1=TEST;
source 2.sh
6.How to find files which was modified in last 30 days?
find . -mtime -30
7.How to find files which was not modified in last 30 days?
find . -mtime 30
8.What is the difference between ONICE and ONHOLD in Autosys?
ONHOLD - if we do OFFHOLD will run at the same occurence.
ONICE - If we do OFFICE will run at the next occurence.
9.How to print the 50th line in a file?
sed '50' p filename ; cat -n filename | grep ^50 ; head -51 filename | tail -1 ;
10.Difference between grep and find?
Grep search using regex pattern .
11.Difference between du and df?
du -sh gives disk usage and df -h gives disk space
12.How to terminate a process in shell?
kill PID ; kill -9 PID ;
13.How to read/list a compressed file?
tar -tvf file.tar
14.How to add a line "TEXT" in the 1st and last line of the file?
echo "TEXT" >> filename ; echo "TEXT" newfile ; cat filename >> newfile ; mv newfile filename

Thanks
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40625008
2: ext2->ext4, zfs,jfs,xfs, ReiserFS,BTRfs,CRFS  

Each has its own advantages and disadvantages http://bit.ly/1JAY3mX

nohup command line-utility which allows to run command/process or shell script that can continue running in the background after you log out from a shell
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 40625282
1. A symbolic link is a file on its own, containing a pointer to another file.
Hard links are just inodes pointing to a file/directory. Several inodes can point to the same file.
2. A filesystem is a structure used to manage (store/retrieve/control)
files, directories and other entities, such as hard/soft links.
3. The shebang tells the calling shell which interpreter (shell) to use
for running the called script.
4. nohup disconnets the called process from the associated tty.
In combination with "&" (backgrounding) the process will survive
the termination of the calling process ("logout" if it's your login shell) even if
there is activity on stdout/stdin/stderr. nohup automaticall redirects
stdout/stderr to a file ~/nohup.out.
5. "export var1=TEST" or "var1=TEST; export var1"
No "sourcing" required from parent to child.
6. find . -type f -mtime -30
7. find . -type f ! -mtime -30 or find . -type f -mtime +30
8. -----
9. sed -n "50p" filename
10. grep inspects the content of files, find inspects the filesystem.
11. "du" reports on the inode level,thus the user running "du" must have
write access to all files and directories,and open files in memory are not seen.  
"df" reports on the filesystem (superblock) level, thus the space occupied
by open files is included.
12. Terminate a foreground process running in your current shell
with <Ctrl><C> which sends an interrupt signal to that process.
Terminate other processes with "kill".
13. A tar archive is not compressed by default, you must specify the "z" flag to compress/uncompress.
tar -ztvf <compressed_archive> to list, tar -zxvf <compressed_archive> to uncompress and exctract.
Use "zcat" or "zmore"/"zless" to view compressed flat files.
14. sed -i.bak -e '1iTEST' -e '$aTEST' filename
 

Note: Question #8 ("Autosys") is beyond my experience.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40626799
Taking the risk that this comment will be deleted by someone and because I did not recognize AutoSys as well, I searched and found this: http://javarevisited.blogspot.nl/2013/08/difference-between-on-hold-and-on-ice-jobs-autosys-interview-question.html?m=1
0
 
LVL 5

Author Comment

by:magento
ID: 40648480
Hi Experts,

I will close this question by weekend. Thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now