Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unix 14 questions

Posted on 2015-02-21
9
Medium Priority
?
105 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 85

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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 84

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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 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…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 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