+ Reply to Thread
Page 2 of 10 First 12 3456 ... Last
Results 26 to 50 of 241
  1. Senior Member
    Join Date
    May 2012
    Location
    IL
    Posts
    215

    Certifications
    LPIC-3, MCITP, RHCE
    #26
    Very nice thread, this is an easy one:
    what is the directory structure of this command ?
    Code:
    mkdir -p myProject/{src,doc/{api,system},tools,db}
    Last edited by log32; 02-09-2013 at 04:31 PM.
    Reply With Quote Quote  

  2. SS -->
  3. The whole Shebang! hiddenknight821's Avatar
    Join Date
    Aug 2009
    Location
    Western NY
    Posts
    1,175

    Certifications
    BS: IT-Security, AAS: Applied Computer Technology, CompTIA Trios, Project+, CCNA: Security (Expired), RHCSA
    #27
    Quote Originally Posted by ChooseLife View Post
    Question #3. So we established that one safe way to clean up a directory is to execute:
    Code:
    $ cd TrashCan && rm -rf *
    Now suppose TrashCan's permissions do not allow the user access its content.
    Is there anything wrong with the following line?
    Code:
    $ sudo cd TrashCan && rm -rf *
    Without cheating, I'd say the first operator (the expression before the double ampersands) would be evaluated as true as long as the correct password is provided. Thus, the last operator would be executed. However, it will not run the `rm -rf *' command on the TrashCan/ directory. It'd be committed to the current directory instead.

    That's the best I can come up with.


    Quote Originally Posted by log32 View Post
    Very nice thread, this is an easy one:
    what is the directory structure of this command ?
    Code:
    mkdir -p myProject/{src,doc/{api,system},tools,db}
    Oh, c'mon. Could you at least give us questions that's at the same level as ChooseLife's? His questions actually made me ponder.

    myProject/src
    myProject/doc
    myProject/doc/api
    myProject/doc/system
    myProject/tools
    myProject/db

    I didn't cheat, but if I'm wrong, then there goes your proof that I didn't.
    Reply With Quote Quote  

  4. 1337sauce
    Join Date
    Jul 2011
    Location
    Ze South
    Posts
    1,539

    Certifications
    BS, Linux+, Security+, LPIC-1, MCSE Server 2012, MCSE Desktop, MCSA Server 2008, MCTS 70-[415,681], MCTS 74-409, VCA-DCV, Novell CLA/DCTS/CNS, HDI CSR
    #28
    Quote Originally Posted by hiddenknight821 View Post
    Oh, c'mon. Could you at least give us questions that's at the same level as ChooseLife's? His questions actually made me ponder.
    TBH I had to think about it. It's not very often I'm mkdir'in beyond the dir needed and it brings an element of "order of operations" a la mathematics to properly evaluate the parent switch directory creation. Same thing with recursive commands...if you don't go beyond what you're doing in that specific directory the specifics can escape you.
    Reply With Quote Quote  

  5. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #29
    Quote Originally Posted by hiddenknight821 View Post
    Without cheating, I'd say the first operator (the expression before the double ampersands) would be evaluated as true as long as the correct password is provided. Thus, the last operator would be executed. However, it will not run the `rm -rf *' command on the TrashCan/ directory. It'd be committed to the current directory instead.
    Good answer. It is partially correct, but does not cover the main "tricky" part of this question
    Reply With Quote Quote  

  6. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #30
    Quote Originally Posted by log32 View Post
    Code:
    mkdir -p myProject/{src,doc/{api,system},tools,db}
    Ah, cool, never had to use nested sets like this, good to know they are possible


    P.S. Keep 'em coming!
    Reply With Quote Quote  

  7. The whole Shebang! hiddenknight821's Avatar
    Join Date
    Aug 2009
    Location
    Western NY
    Posts
    1,175

    Certifications
    BS: IT-Security, AAS: Applied Computer Technology, CompTIA Trios, Project+, CCNA: Security (Expired), RHCSA
    #31
    Quote Originally Posted by lsud00d View Post
    TBH I had to think about it. It's not very often I'm mkdir'in beyond the dir needed and it brings an element of "order of operations" a la mathematics to properly evaluate the parent switch directory creation. Same thing with recursive commands...if you don't go beyond what you're doing in that specific directory the specifics can escape you.
    I do not mean to belittle the question, and I apologize if Log32 finds it offensive. I just didn't think it's as "tricky" or comparative to ChooseLife's, but to each his own, I suppose. Although, I couldn't disagree with your statement as we all tend to forget commands we don't use very often. It just happened that I've been studying Linux for quite awfully a long time since July. I recalled this recursive command from the LFS project I was doing over the summer, and it certainly helped.

    Quote Originally Posted by ChooseLife View Post
    Good answer. It is partially correct, but does not cover the main "tricky" part of this question
    Okay. The more I think about it, the trickier it gets. Since I had it partially correct, I believe the `rm -rf' command didn't even execute at all, because it requires root privilege. Beat me! I might as well go ahead and cheat to find out... in the VM, of course, you slick, sick, sadist.
    Reply With Quote Quote  

  8. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #32
    Tricky questions are actually quite hard to come up with... So thanks for the positive feedback guys
    Reply With Quote Quote  

  9. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #33
    Quote Originally Posted by hiddenknight821 View Post
    The more I think about it, the trickier it gets. Since I had it partially correct, I believe the `rm -rf' command didn't even execute at all, because it requires root privilege.
    Not really, "rm" itself doesn't know that it requires a root privilege to finish successfully - it just tries and fails with a "permission denied" message. If I misunderstood what you meant, please tell me.

    Quote Originally Posted by hiddenknight821 View Post
    I might as well go ahead and cheat to find out... in the VM, of course, you slick, sick, sadist.
    Do go ahead and play with it, these questions are not a mental exercise as Linux is a very hands-on and practical subject. And of course you don't need to use "rm", instead substitute it with any other command. Especially useful are "debugging" commands such as "pwd", "id", "echo $VAR", "echo $?", however you must really know scope/visibility/lifetime of various elements to debug these things correctly.
    Reply With Quote Quote  

  10. The whole Shebang! hiddenknight821's Avatar
    Join Date
    Aug 2009
    Location
    Western NY
    Posts
    1,175

    Certifications
    BS: IT-Security, AAS: Applied Computer Technology, CompTIA Trios, Project+, CCNA: Security (Expired), RHCSA
    #34
    Quote Originally Posted by ChooseLife View Post
    Not really, "rm" itself doesn't know that it requires a root privilege to finish successfully - it just tries and fails with a "permission denied" message. If I misunderstood what you meant, please tell me.
    Assuming you're talking about a typical user executing the command and the TrashCan directory has the 700 permission that belongs to root, then yes I had the right idea that root privilege was required. Otherwise, "permission denied" message is expected.

    Anyway, all my guesses were wrong and I finally took your advice. After testing it, I was mind-blowned! It didn't execute at all, because 'sudo' cannot find 'cd' command. I'm glad you brought this to our attentions. Like I said, you come up with good trick questions. I'm surprised none of the books I read so far warned me about using built-in shell command with the sudo commands, especially in scripting. So next time something funny like that happen, I'd make sure to use the type/which/whereis commands before I go nuts.
    Reply With Quote Quote  

  11. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #35
    Quote Originally Posted by hiddenknight821 View Post
    After testing it, I was mind-blowned! It didn't execute at all, because 'sudo' cannot find 'cd' command. I'm glad you brought this to our attentions. Like I said, you come up with good trick questions. I'm surprised none of the books I read so far warned me about using built-in shell command with the sudo commands, especially in scripting. So next time something funny like that happen, I'd make sure to use the type/which/whereis commands before I go nuts.
    You nailed it! Props for persistently digging to the bottom of it and finding the right answer.

    So, the correct answer is:
    In this example, "sudo cd TrashCan" will fail to execute because "cd" unlike many other commands is not a standalone program but rather is a shell builtin, and sudo works on standalone executable programs only. There are many ways to work around this restriction, my preference is to run it as
    Code:
    $ sudo bash -c "cd TrashCan && rm -rf *"
    Reply With Quote Quote  

  12. Are we having fun yet? UnixGuy's Avatar
    Join Date
    Mar 2008
    Posts
    3,327

    Certifications
    GCFA, eJPT, RHCE, Solaris 10, SNIA SCSP, Security+, Server+, ITILv3, CCNA (Expired)
    #36
    +1 excellent thread! Keep them coming
    Goal: GCFA (DONE), GPEN
    Reply With Quote Quote  

  13. Are we having fun yet? UnixGuy's Avatar
    Join Date
    Mar 2008
    Posts
    3,327

    Certifications
    GCFA, eJPT, RHCE, Solaris 10, SNIA SCSP, Security+, Server+, ITILv3, CCNA (Expired)
    #37
    Question: I have a peculiar file named "~" in my home directory, how do I delete it?

    [root@station1 ~]# ls -l
    total 76
    -rw-r--r-- 1 root root 0 Feb 18 12:10 ~
    -rw------- 1 root root 1253 Oct 17 2011 anaconda-ks.cfg
    drwxr-xr-x 3 root root 4096 Oct 21 2011 Desktop
    -rw-r--r-- 1 root root 31401 Oct 17 2011 install.log
    -rw-r--r-- 1 root root 4919 Oct 17 2011 install.log.syslog
    -rw------- 1 root root 11727 Oct 18 2011 mbox
    [root@station1 ~]#



    Goal: GCFA (DONE), GPEN
    Reply With Quote Quote  

  14. Senior Member dontstop's Avatar
    Join Date
    Dec 2011
    Posts
    514

    Certifications
    CompTIA IT Fundamentals, CCENT, CCNA:R&S, BInfoTech
    #38
    rm -rf -- \~
    Reply With Quote Quote  

  15. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #39
    Quote Originally Posted by UnixGuy View Post
    +1 excellent thread! Keep them coming
    Thank you! I hope you will contribute your share of quirky questions too
    Reply With Quote Quote  

  16. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #40
    Quote Originally Posted by dontstop View Post
    rm -rf -- \~
    agreed. for safety, i'd make couple changes to it:

    a) drop "-rf" - the regular file won't need it but it can hurt if something goes sideways and the home directory will be attempted to get removed

    b) throw "./" in for a good measure

    so my answer is

    Code:
    rm -- ./\~
    Reply With Quote Quote  

  17. Are we having fun yet? UnixGuy's Avatar
    Join Date
    Mar 2008
    Posts
    3,327

    Certifications
    GCFA, eJPT, RHCE, Solaris 10, SNIA SCSP, Security+, Server+, ITILv3, CCNA (Expired)
    #41
    @dontstop & @ChooseLife

    Correct answers.

    This is enough though:
    Code:
    [root@station1 ~]# rm \~
    Since we escaped the special character "~" ...RM using the full path:
    Code:
    [root@station1 ~]# rm ~/\~
    rm: remove regular empty file `/root/~'? y
    [root@station1 ~]# ls -l
    total 76
    -rw------- 1 root root  1253 Oct 17  2011 anaconda-ks.cfg
    drwxr-xr-x 3 root root  4096 Oct 21  2011 Desktop
    -rw-r--r-- 1 root root 31401 Oct 17  2011 install.log
    -rw-r--r-- 1 root root  4919 Oct 17  2011 install.log.syslog
    -rw------- 1 root root 11727 Oct 18  2011 mbox
    [root@station1 ~]#
    Goal: GCFA (DONE), GPEN
    Reply With Quote Quote  

  18. Senior Member MentholMoose's Avatar
    Join Date
    Sep 2009
    Location
    CA
    Posts
    1,550
    #42
    Question: Is KVM a Type 1 or Type 2 hypervisor? Explain your answer.
    Reply With Quote Quote  

  19. Senior Member
    Join Date
    Feb 2012
    Posts
    2,426
    #43
    If I recall correctly - I believe that KVM is a type 1 hypervisor. It runs in the kernel directly on the hardware and exposes the hardware through a device file (can't remember which) for guest systems. It doesn't run an an app in userland which I recall is the definition of a type 2 hypervisor. Something like that
    Reply With Quote Quote  

  20. Senior Member W Stewart's Avatar
    Join Date
    Jun 2011
    Location
    Tampa, FL
    Posts
    786

    Certifications
    Bachelor of Science IT - Security, CCNA Security, CCNA R&S, LPIC-1, A+ Net+ Sec+, Linux+ and others I don't feel are worth mentioning
    #44
    Okay, I've been trying to think up a question for awhile and this is something I just happened to come across a week ago.

    I wrote an upstart init script and put it in the /etc/init.d/ directory. I'm using CentOS but I don't want to use chkconfig to start the service. Assuming the script has everything it needs (i.e, start on runlevel [2345]), what can I do to start the service at boot. (There's more than one way to accomplish this but the way I did it seems to be the way chkconfig does it as well.)
    Last edited by W Stewart; 03-02-2013 at 11:37 AM.
    Reply With Quote Quote  

  21. The whole Shebang! hiddenknight821's Avatar
    Join Date
    Aug 2009
    Location
    Western NY
    Posts
    1,175

    Certifications
    BS: IT-Security, AAS: Applied Computer Technology, CompTIA Trios, Project+, CCNA: Security (Expired), RHCSA
    #45
    Well, you got a few options. The best way to be sure that you are doing them properly is to manually create the symbolic links in each desirable run-level directory under /etc/rc.d/ directory. Each symlink has to either start with 'S' or 'K' followed by a number in collating sequence with script name suffix. S is for start and K is for kill. The number is important as you may want to start up the firewall before networking. The chkconfig is doing all the dirty works for us which is implied by the `rpm -ql chkconfig' command.

    The script file that each symlink is being linked to has to be placed in the /etc/init.d/ directory with all of the applicable case options such as start, stop, reload, restart, and so forth. It's probably best to use an initd script template and build the script from there.

    Although, I know there is a place in /etc/rc.local where you can throw in any script that you want to run after the host's done booting up, but this wouldn't be appropriate for the iptables service. Beside, the script runs regardless of the run-level you are in.
    Reply With Quote Quote  

  22. Senior Member W Stewart's Avatar
    Join Date
    Jun 2011
    Location
    Tampa, FL
    Posts
    786

    Certifications
    Bachelor of Science IT - Security, CCNA Security, CCNA R&S, LPIC-1, A+ Net+ Sec+, Linux+ and others I don't feel are worth mentioning
    #46
    Quote Originally Posted by hiddenknight821 View Post
    Well, you got a few options. The best way to be sure that you are doing them properly is to manually create the symbolic links in each desirable run-level directory under /etc/rc.d/ directory. Each symlink has to either start with 'S' or 'K' followed by a number in collating sequence with script name suffix. S is for start and K is for kill. The number is important as you may want to start up the firewall before networking. The chkconfig is doing all the dirty works for us which is implied by the `rpm -ql chkconfig' command.

    The script file that each symlink is being linked to has to be placed in the /etc/init.d/ directory with all of the applicable case options such as start, stop, reload, restart, and so forth. It's probably best to use an initd script template and build the script from there.

    Although, I know there is a place in /etc/rc.local where you can throw in any script that you want to run after the host's done booting up, but this wouldn't be appropriate for the iptables service. Beside, the script runs regardless of the run-level you are in.
    That's about how I did it. I just got a little curious about how upstart handled services after using slackware for awhile. It's very good to know.
    Reply With Quote Quote  

  23. Senior Member ChooseLife's Avatar
    Join Date
    Feb 2011
    Location
    runlevel 3
    Posts
    926

    Certifications
    BCSc Network Security, VCP, MCSA:Sec, CCNA:Sec, GIAC GSEC, Sec+, ITIL-f
    #47
    Actually, using S and K files in /etc/rc.d/rcX.d is a fundamental way of managing daemons start/stop in System V-like Linuces (e.g. RedHat) - it is one of the differences between them and BSD-like Linuces (e.g. Slackware). Tools like chkconfig just partially automate/simplify this process.
    Reply With Quote Quote  

  24. Are we having fun yet? UnixGuy's Avatar
    Join Date
    Mar 2008
    Posts
    3,327

    Certifications
    GCFA, eJPT, RHCE, Solaris 10, SNIA SCSP, Security+, Server+, ITILv3, CCNA (Expired)
    #48
    Quote Originally Posted by ChooseLife View Post
    Actually, using S and K files in /etc/rc.d/rcX.d is a fundamental way of managing daemons start/stop in System V-like Linuces (e.g. RedHat) - it is one of the differences between them and BSD-like Linuces (e.g. Slackware). Tools like chkconfig just partially automate/simplify this process.

    True, that's how it's done in Solaris (up to Solaris 9). From Solaris 10 onwards, they introduced service management facility to take care of that.
    Goal: GCFA (DONE), GPEN
    Reply With Quote Quote  

  25. Senior Member MentholMoose's Avatar
    Join Date
    Sep 2009
    Location
    CA
    Posts
    1,550
    #49
    Quote Originally Posted by paul78 View Post
    If I recall correctly - I believe that KVM is a type 1 hypervisor. It runs in the kernel directly on the hardware and exposes the hardware through a device file (can't remember which) for guest systems. It doesn't run an an app in userland which I recall is the definition of a type 2 hypervisor. Something like that
    AFAIK this is correct. The trouble is that KVM seems to have some type 2 qualities. For example, you can load/unload the kernel module for it on the fly, similar to VMware Workstation or VirtualBox. I used to think of it as a "type 1.5" hypervisor, but I attended a presentation at SCALE recently and the "chief virtualization architect" at IBM said it was definitely a type 1 hypervisor, so I'll go with that.
    Reply With Quote Quote  

  26. Senior Member MentholMoose's Avatar
    Join Date
    Sep 2009
    Location
    CA
    Posts
    1,550
    #50
    Okay this thread is supposed to be "question of the day", so post more questions. IMO it doesn't need to be anything tricky.

    Question
    : It's 4:55 PM and you're about to exit your SSH sessions, power off your laptop, and go home, but your boss tells you to download a large file / compile a program / run a lengthy SQL query / etc. on a remote server before you leave so it's ready tomorrow. What should you do in your SSH session to that server to allow the task to continue when you close the session?
    Reply With Quote Quote  

+ Reply to Thread
Page 2 of 10 First 12 3456 ... Last

Social Networking & Bookmarks