EzDevInfo.com

command-line-interface interview questions

Top command-line-interface frequently asked interview questions

What's the command-line utility in Windows to do a reverse DNS look-up?

Is there a built-in command line tool that will do reverse DNS look-ups in Windows? I.e., something like <toolname> w.x.y.z => mycomputername

I've tried:

  • nslookup: seems to be forward look-up only.
  • host: doesn't exist
  • dig: also doesn't exist.

I found "What's the reverse DNS command line utility?" via a search, but this is specifically looking for a *nix utility, not a Windows one.


Source: (StackOverflow)

Does Windows have a built-in ZIP command for the command line?

Since Windows Explorer (since at least Windows XP) has some basic support for ZIP files, it seems like there should be a command-line equivalent, but I can't seem to find any sign of one.

Does Windows (XP, Vista, 7, 8, 2003, 2008, 2013) ship with a built-in command-line zip tool, or do I need to stick with third-party tools?


Source: (StackOverflow)

Advertisements

Biggest command-line mistake? [closed]

What is the most damage (of whatever kind) that you have ever caused with a single mistaken/mistyped/misguided command line? I deleted a production system database by mistake a while back, for example, but I was lucky (i.e. backed-up) and there was no permanent data loss, lost money, property damage etc.

Most importantly (for votes), what do you do to make sure it will not ever happen again?


Source: (StackOverflow)

How to cd into a directory with this name "-2" (starting with the hyphen)?

I have a directory named:

-2

I want to cd into it but the cd complains:

bash: cd: -2: invalid option

With no success, I've tried:

cd "-2"
cd '-2'
cd \-2

Any solution?

Edit: no file browsers like mc, etc. available on the server.


Source: (StackOverflow)

How to zip/unzip files in Powershell?

Is there a one-liner that will zip/unzip files (*.zip) in PowerShell?


Source: (StackOverflow)

Run a .bat file in a scheduled task without a window

I have a scheduled task that starts a batch script that runs robocopy every hour. Every time it runs a window pops up on the desktop with robocopy's output, which I don't really want to see.

I managed to make the window appear minimized by making the scheduled job run

cmd /c start /min mybat.bat

but that gives me a new command window every hour. I was surprised by this, given cmd /c "Carries out the command specified by string and then terminates" - I must have misunderstood the docs.

Is there a way to run a batch script without it popping up a cmd window?


Source: (StackOverflow)

Useful Command-line Commands on Windows

The aim for this Wiki is to promote using a command to open up commonly used applications without having to go through many mouse clicks - thus saving time on monitoring and troubleshooting Windows machines.

Answer entries need to specify

  • Application name
  • Commands
  • Screenshot (Optional)

Shortcut to commands


Source: (StackOverflow)

Favorite Unix command line aliases? [closed]

What are your favorite command line aliases (bash/sh/tcsh) aliases? Here are a few of mine.

alias lsr='ls -lrt'
alias gon='cd $HOME/Notes'
alias devdb='mysql -h dev --user=x --password=secret dbname'
alias ec='rm *~'; # emacs cleanup
alias h='history'
alias eb='exec bash'; # Solaris sometimes defaults to sh
alias mr='more'
alias mroe='more'
alias qd='echo export DISPLAY=$DISPLAY'
alias ralias='. $HOME/.alias'; # reread aliases
alias ,,='cd ../..'
alias ..='cd ..'
alias c='clear'

Source: (StackOverflow)

How to display certain lines from a text file in Linux?

I guess everyone knows the useful Linux cmd line utilities head and tail. head allows you to print the first X lines of a file, tail does the same but prints the end of the file. What is a good command to print the middle of a file? something like middle --start 10000000 --count 20 (print the 10’000’000th till th 10’000’010th lines).

I'm looking for something that will deal with large files efficiently. I tried tail -n 10000000 | head 10 and it's horrifically slow.


Source: (StackOverflow)

How can I get diff to show only added and deleted lines? If diff can't do it, what tool can?

How can I get diff to show only added and deleted lines? If diff can't do it, what tool can?


Source: (StackOverflow)

Nginx enable site command

We all know how to enable a website using apache on linux. I'm pretty sure that we all agree on using the a2ensite command.

Unfortunately there is no default equivalent command comes with Nginx, but it did happens that I installed some package on ubuntu that allowed me to enable/disable sites and list them.

The problem is I don't remember the name of this package.

Anybody knows what I'm talking about?

Please tell me name of this package and the command name.

Update:

Go straight to answer the script is there just run it and everything is well explained.


Source: (StackOverflow)

What are useful Command-line Commands on Mac OS X?

Per the Windows and Linux threads, what commands do you find most useful in Mac OS X Server (or Client)?


Source: (StackOverflow)

Recursive text search with grep and file patterns

Given this example folder structure:

/folder1/file1.txt
/folder1/file2.djd
/folder2/file3.txt
/folder2/file2.fha

How do I do a recursive text search on all *.txt files with grep from "/"?

("grep -r <pattern> *.txt" fails when run from "/", since there are no .txt files in that folder.)


Source: (StackOverflow)

How to sort ps output by process start time?

Is there a way to sort ps output by process start time, so newest are either at the top or bottom ?

On Linux ?

On SysV5 ?

On Mac ?


Source: (StackOverflow)

Tools a Unix administrator cannot live without [closed]

After administering Unix or Unix-like servers, what tools (command-line preferably) do you feel you cannot live without?


Source: (StackOverflow)