Solved

Unix 14 questions

Posted on 2015-02-21
9
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 84

Expert Comment

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

Expert Comment

by:Gerwin Jansen, EE MVE
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
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 82

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 38

Expert Comment

by:Gerwin Jansen, EE MVE
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

623 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