command-line-interface interview questions
Top command-line-interface frequently asked interview questions
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)
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)
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)
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)
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)
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
- && - Command Chaining
- %SYSTEMROOT%\System32\rcimlby.exe -LaunchRA - Remote Assistance (Windows XP)
- appwiz.cpl - Programs and Features (Formerly Known as "Add or Remove Programs")
- appwiz.cpl @,2 - Turn Windows Features On and Off (Add/Remove Windows Components pane)
- arp - Displays and modifies the IP-to-Physical address translation tables used by address resolution protocol (ARP)
- at - Schedule tasks either locally or remotely without using Scheduled Tasks
- bootsect.exe - Updates the master boot code for hard disk partitions to switch between BOOTMGR and NTLDR
- cacls - Change Access Control List (ACL) permissions on a directory, its subcontents, or files
- calc - Calculator
- chkdsk - Check/Fix the disk surface for physical errors or bad sectors
- cipher - Displays or alters the encryption of directories [files] on NTFS partitions
- cleanmgr.exe - Disk Cleanup
- clip - Redirects output of command line tools to the Windows clipboard
- cls - clear the command line screen
- cmd /k - Run command with command extensions enabled
- color - Sets the default console foreground and background colors in console
- command.com - Default Operating System Shell
- compmgmt.msc - Computer Management
- control.exe /name Microsoft.NetworkAndSharingCenter - Network and Sharing Center
- control keyboard - Keyboard Properties
- control mouse(or main.cpl) - Mouse Properties
- control sysdm.cpl,@0,3 - Advanced Tab of the System Properties dialog
- control userpasswords2 - Opens the classic User Accounts dialog
- desk.cpl - opens the display properties
- devmgmt.msc - Device Manager
- diskmgmt.msc - Disk Management
- diskpart - Disk management from the command line
- dsa.msc - Opens active directory users and computers
- dsquery - Finds any objects in the directory according to criteria
- dxdiag - DirectX Diagnostic Tool
- eventvwr - Windows Event Log (Event Viewer)
- explorer . - Open explorer with the current folder selected.
- explorer /e, . - Open explorer, with folder tree, with current folder selected.
- F7 - View command history
- find - Searches for a text string in a file or files
- findstr - Find a string in a file
- firewall.cpl - Opens the Windows Firewall settings
- fsmgmt.msc - Shared Folders
- fsutil - Perform tasks related to FAT and NTFS file systems
- ftp - Transfers files to and from a computer running an FTP server service
- getmac - Shows the mac address(es) of your network adapter(s)
- gpedit.msc - Group Policy Editor
- gpresult - Displays the Resultant Set of Policy (RSoP) information for a target user and computer
- httpcfg.exe - HTTP Configuration Utility
- iisreset - To restart IIS
- InetMgr.exe - Internet Information Services (IIS) Manager 7
- InetMgr6.exe - Internet Information Services (IIS) Manager 6
- intl.cpl - Regional and Language Options
- ipconfig - Internet protocol configuration
- lusrmgr.msc - Local Users and Groups Administrator
- msconfig - System Configuration
- notepad - Notepad? ;)
- mmsys.cpl - Sound/Recording/Playback properties
- mode - Configure system devices
- more - Displays one screen of output at a time
- mrt - Microsoft Windows Malicious Software Removal Tool
- mstsc.exe - Remote Desktop Connection
- nbstat - displays protocol statistics and current TCP/IP connections using NBT
- ncpa.cpl - Network Connections
- netsh - Display or modify the network configuration of a computer that is currently running
- netstat - Network Statistics
- net statistics - Check computer up time
- net stop - Stops a running service.
- net use - Connects a computer to or disconnects a computer from a shared resource, displays information about computer connections, or mounts a local share with different privileges (documentation)
- odbcad32.exe - ODBC Data Source Administrator
- pathping - A traceroute that collects detailed packet loss stats
- perfmon - Opens Reliability and Performance Monitor
- ping - Determine whether a remote computer is accessible over the network
- powercfg.cpl - Power management control panel applet
- qfecheck - Shows installed Hotfixes applied to the server/workstation.
- quser - Display information about user sessions on a terminal server
- qwinsta - See disconnected remote desktop sessions
- reg.exe - Console Registry Tool for Windows
- regedit - Registry Editor
- rasdial - Connects to a VPN or a dialup network
- robocopy - Backup/Restore/Copy large amounts of files reliably
- rsop.msc - Resultant Set of Policy (shows the combined effect of all group policies active on the current system/login)
- runas - Run specific tools and programs with different permissions than the user's current logon provides
- sc - Manage anything you want to do with services.
- schtasks - Enables an administrator to create, delete, query, change, run and end scheduled tasks on a local or remote system.
- secpol.msc - Local Security Settings
- services.msc - Services control panel
- set - Displays, sets, or removes cmd.exe environment variables.
- set DIRCMD - Preset dir parameter in cmd.exe
- start - Starts a separate window to run a specified program or command
- start. - opens the current directory in the Windows Explorer.
- shutdown.exe - Shutdown or Reboot a local/remote machine
- subst.exe - Associates a path with a drive letter, including local drives
- systeminfo -Displays a comprehensive information about the system
- taskkill - terminate tasks by process id (PID) or image name
- tasklist.exe - List Processes on local or a remote machine
- taskmgr.exe - Task Manager
- telephon.cpl - Telephone and Modem properties
- timedate.cpl - Date and Time
- title - Change the title of the CMD window you have open
- tracert - Trace route
- whoami /all - Display Current User/Group/Privilege Information
- wmic - Windows Management Instrumentation Command-line
- winver.exe - Find Windows Version
- wscui.cpl - Windows Security Center
- wuauclt.exe - Windows Update AutoUpdate Client
Source: (StackOverflow)
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)
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?
Source: (StackOverflow)
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)
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)
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)
After administering Unix or Unix-like servers, what tools (command-line preferably) do you feel you cannot live without?
Source: (StackOverflow)