Questions tagged [command-line-interface]
A command-line interface (CLI) is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks.
114
questions
279
votes
160
answers
320k
views
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 ...
104
votes
2
answers
364k
views
How can I connect to a Windows server using a Command Line Interface? (CLI)
Especially with the option to install Server Core in Server 2008 and above, connecting to Windows servers over a CLI is increasingly useful ability, if not one that's very widespread amongst Windows ...
42
votes
8
answers
92k
views
Force local IP traffic to an external interface
I have a machine with several interfaces that I can configure as I want, for instance:
eth1: 192.168.1.1
eth2: 192.168.2.2
I would like to forward all the traffic sent to one of these local ...
41
votes
5
answers
8k
views
Smoothest workflow to handle SSH host verification errors?
This is a simple issue that we all face and probably resolve manually without giving much thought.
As servers change, are re-provisioned, or IP addresses reallocated, we receive the SSH host ...
196
votes
6
answers
67k
views
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 ...
33
votes
5
answers
79k
views
block all but a few ips with firewalld
On a linux networked machine, i would like to restrict the set of addresses on the "public" zone (firewalld concept), that are allowed to reach it. So the end result would be no other machine can ...
177
votes
11
answers
360k
views
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 ...
141
votes
39
answers
150k
views
What useful things can one add to one's .bashrc? [closed]
Is there anything that you can't live without and will make my life SO much easier? Here are some that I use ('diskspace' & 'folders' are particularly handy).
# some more ls aliases
alias ll='ls -...
58
votes
55
answers
92k
views
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)?
35
votes
81
answers
9k
views
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,...
35
votes
6
answers
110k
views
KVM Guest installed from console. But how to get to the guest's console?
I'm trying to install a fully virtualized guest (Fedora 14 x86_64) on KVM (RHEL 6), using command-line only (both hypervisor and guest). It goes without errors, and without a tangible result . I'd ...
20
votes
2
answers
153k
views
Command to remove computer from non-existant domain
I lost my domain controller machine, and then add new domain controller but with a new domain. How do I remove network machines from old domain using command line and add to new domain? Machines ...
19
votes
11
answers
24k
views
How does one find which files are taking up 80% of the space on a Linux webserver?
The drive is constantly filling up. You've hunted down all the spare and random files you can. grep'd for coredump files and even removed some of the un-needed backups...
What would be your next move....
11
votes
2
answers
6k
views
linux command to prevent dos attack by using netstat and iptables
I want to DROP more than 200 requests per ip to prevent ddos attack. this is command that i used to detect requests count per ip :
netstat -alpn | grep :80 | awk '{print $5}' |awk -F: '{print $(NF-1)}...
42
votes
6
answers
6k
views
Avoid to keep command in history
I use bash and I would like to avoid some commands being kept in the history.
Is it possible to do that for the next command only?
Is it possible to do that for the entire session?
19
votes
2
answers
84k
views
What is the difference between sudo -i and sudo su -
What is the difference between commands sudo -i and sudo su -?
Are they the same?
9
votes
10
answers
6k
views
Useful Commandline Commands on Unix
As there is a windows version of this question, I decided to open a community wiki for the same question under unix, linux, and the like.
I'll be updating this list with the answers:
bash: exec 3&...
3
votes
1
answer
14k
views
Reverse DNS Lookup from the Command Line
I'd like to get a list of all domains pointed to a certain IP address. Is there a way to get this information from the command line?
Nothing like "host", "nslookup" or "dig -x". Those return the ...
197
votes
10
answers
521k
views
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 that comes with Nginx, ...
186
votes
31
answers
102k
views
How do I prevent accidental rm -rf /*?
I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash).
alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for ...
44
votes
9
answers
58k
views
How to hide a password passed as command line argument?
I'm running a software daemon that requires for certain actions to enter a passphrase to unlock some features which looks for example like that:
$ darkcoind masternode start <mypassphrase>
Now ...
44
votes
3
answers
94k
views
What is the command to flash a NIC link light?
I remember using a command line tool to flash a NIC's link light to identify it. I can't remember for the life of me what it was.
38
votes
4
answers
428k
views
How to check who is currently logged on to windows workstation from command line?
Environment is in domain, server is Windows Server 2003, workstations have Vista and XP installed.
I need the way to check remotely who is currently logged on workstation, preferably from some simple ...
29
votes
4
answers
46k
views
Adding a random delay for a Linux command
I am using func to perform parallel commands on our servers.
The other day, we had an issue when a service restart of puppet via func made all our severs hit our puppetmaster at the same time.
My ...
22
votes
4
answers
18k
views
How to edit command completion for ssh on zsh?
I'd like to set up command completion on zsh to display host names after I type
ssh [TAB]
taking the names out of my .ssh/config file (and preferably from known_hosts and /etc/hosts and anywhere ...
22
votes
4
answers
60k
views
VPN client connect/disconnect via command line in XP
In an XP Pro workstation, is there a way to start the native Windows VPN client and open/close a connection from the command line so it can be scripted in a batch file?
10
votes
9
answers
18k
views
Easiest way to email file via command line in *nix?
What is the easiest - and preferably most portable - command I can use to email a single file as an attachment a *nix shell?
6
votes
2
answers
10k
views
Terminal Server - Group Policy prevent command line
I have a Windows 2008 Terminal Server. Terminal Server Configuration(licence server, session broker, etc) is managed by group policy. If i want to disable logon via:
change logon /disable
The Error ...
3
votes
2
answers
34k
views
How to shutdown a virtual machine on ESXi5 over an ssh terminal session?
How can I shutdown a virtual machine when I am on the commandline of an ESXi5 host over ssh?
Sidenote:
To enable scripts on other machines to login to the ESXi without password, add the public key ...
3
votes
3
answers
2k
views
How to add a web folder via command line (Windows)
I am trying to add a web folder via command line in windows. At first I though I should use the "net use" command, but when I tried I kept getting System error 67:
C:>net use *
http://dev....
2
votes
3
answers
10k
views
Windows Server 2008, "The requested operation requires elevation"
Sorry for the newbe question, but I'm a developer who hasn't touch a Windows Server in years. A recent project has required me to setup and configure a development VM running Windows Server 2008, IIS ...
2
votes
2
answers
7k
views
Send message to another Computer through Network via CmdLine
I would like to send from a server ( Windows 2008 R2) a pop up message to another Computer in the Network (Windows 7). I already enable AllowRemoteRPC in the registry of my Windows 7 system.
This cmd ...
1
vote
0
answers
974
views
ssh reverse tunnel port forwarding connection fails
I am able to do a reverse port forwarding through the PUTTY GUI with settings similar to below. Once I apply this setting, I am able to run to the server box and run wget http://localhost:8080 <-- ...
1
vote
3
answers
22k
views
How to safely kick out other users logged in as root?
I tried this:
pkill -KILL -u root
It turns out that wasn't what I wanted. Now I can't log in by SSH.
What is the correct way?
Edit - I've added the word "safely" to the question.
I know that you ...
0
votes
4
answers
2k
views
403 Forbidden Access
Yesterday my supervisor mounted one of his directories onto my server. The problem is, I can't access them and I have no way of contacting him right now. When I type in the URL I get this error:
...
193
votes
9
answers
1.3m
views
Resolve host name from IP address
I'm looking for a command line tool which gets an IP address and returns the host name, for Windows.
137
votes
14
answers
180k
views
What's the reverse DNS command line utility?
What's the command to find the name of a computer given its IP address?
I always forget what this command is, but I know it exists in Windows and I assume it exists on the *nix command-line.
132
votes
7
answers
420k
views
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 ...
103
votes
11
answers
140k
views
How to zip/unzip files in Powershell?
Is there a one-liner that will zip/unzip files (*.zip) in PowerShell?
86
votes
7
answers
143k
views
What is the Windows equivalent of Unix "whoami" command?
Is there a Windows equivalent of Unix "whoami" command? If so, what is it?
67
votes
18
answers
103k
views
How to ping in linux until host is known?
How can I ping a certain address and when found, stop pinging.
I want to use it in a bash script, so when the host is starting up, the script keeps on pinging and from the moment the host is ...
61
votes
7
answers
143k
views
Force SSH to use a specific shell
Is there any way to force SSH to use a particular shell on the remote end, regardless of what the user's default shell is?
I've tried solutions akin to:
ssh host.domain.com /bin/bash -c 'complicated,...
60
votes
1
answer
18k
views
What is the difference between a 'Login' and an 'Interactive' bash shell
What is the difference between a ‘Login’ and an ‘Interactive’ bash shell?
I have quoted Wikipedia below but can anybody give a better answer?
EDIT: This is a community wiki so maybe rather than voting ...
57
votes
4
answers
105k
views
Linux command line character limit
I'm passing a variable to a script on the command line. What is the character limit of a command? eg:
$ MyScript reallyreallyreally...reallyreallyreallylongoption
Thanks.
47
votes
7
answers
48k
views
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 -...
45
votes
3
answers
129k
views
How to view hidden files using Linux `find` command
On a Linux server, I need to find all files with a certain file extension in the current directory and all sub-directories.
Previously, I have always used the following command:
find . -type f | grep -...
39
votes
16
answers
264k
views
How to get own process pid from the command prompt in Windows
I'm trying to find a way to get my own PID from a command prompt (for later use in bat scripts).
So far the only useful way I found was to use getpids.exe from here : http://www.scheibli.com/projects/...
39
votes
52
answers
8k
views
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'...
38
votes
7
answers
54k
views
Ssh, run a command on login, and then Stay Logged In?
I tried this with expect, but it didn't work: it closed the connection at the end.
Can we run a script via ssh which will log into remote machines, run a command, and not disconnect?
So ssh in a ...
36
votes
7
answers
59k
views
Delete Files Older than (x) Days?
What's a good Windows command line option for deleting all files in a given folder older than (n) days?
Also note there may be many thousands of these files, so forfiles with a shell to cmd is not a ...