Solved

Unix 14 questions

Posted on 2015-02-21
9
80 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
Comment Utility
Consulting the unix man pages is a good method.
0
 
LVL 37

Expert Comment

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

Author Comment

by:magento
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi Experts,

I will close this question by weekend. Thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

16 Experts available now in Live!

Get 1:1 Help Now