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.
1,583
questions
310
votes
14
answers
1.0m
views
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-...
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 ...
197
votes
10
answers
522k
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, ...
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 ...
194
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.
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 ...
177
votes
11
answers
361k
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 ...
169
votes
9
answers
573k
views
How to remove empty/blank lines from a file in Unix (including spaces)?
How do I remove empty/blank (including spaces only) lines in a file in Unix/Linux using the command line?
contents of file.txt
Line:Text
1:<blank>
2:AAA
3:<blank>
4:BBB
5:<blank>
6:...
155
votes
13
answers
327k
views
How do I find the UUID of a file system?
I'm running Ubuntu, and want to find out the UUID of a particular filesystem (not partition). I know I can use e2label /dev/sda1 to find out the file system label, but there doesn't seem to be a ...
150
votes
6
answers
178k
views
Show full process name in top
I'm running a Rails stack on Ubuntu.
When I call ps -AF, I get a descriptive process name set by the Apache module like
00:00:43 Rails: /var/www...
which is really helpful in diagnosing load issues.
...
144
votes
11
answers
535k
views
Run Oracle SQL script and exit from sqlplus.exe via command prompt
I would like to run an Oracle script through SQL Plus via a Windows command prompt. The script does not contain an "exit" command, but I would still like SQL Plus to exit, returning control to the ...
143
votes
9
answers
327k
views
Find out symbolic link target via command line
Say that I setup a symbolic link:
ln -s /root/Public/mytextfile.txt /root/Public/myothertextfile.txt
is there a way to see what the target of myothertextfile.txt is using the command line?
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 -...
138
votes
14
answers
181k
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 ...
113
votes
10
answers
325k
views
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 ...
105
votes
11
answers
111k
views
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?
104
votes
3
answers
180k
views
How to get the url of the current svn repo?
I have 2 svn checkouts that someone setup for me. Now I need to check these same files on another computer, but since I didn't check them out initially I don't know the urls to use when running the ...
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 ...
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?
93
votes
7
answers
117k
views
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 ?
87
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?
70
votes
6
answers
282k
views
How can I query my system via command line to see if a KB patch is installed?
I'm looking to find out if a KB is installed via command line.
69
votes
3
answers
215k
views
php cli memory limit
I am getting a memory error in a php cron job:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /opt/matrix/core/lib/DAL/DAL.inc on line 830
The ...
68
votes
3
answers
32k
views
GNU less: How can I search while ignoring case sensitivity without using less -I option?
From GNU less manpage
-i or --ignore-case
Causes searches to ignore case; that is, uppercase and lowercase are considered identical.
This option is ignored if any uppercase letters appear in the ...
67
votes
18
answers
104k
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
144k
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
19k
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 ...
59
votes
6
answers
124k
views
How to automatically close netcat connection after data is sent?
I am executing the following command from a script:
echo '{"hostUp": true}' | sudo /usr/local/bin/netcat localhost 8001
However, the netcat client stays open indefinitely. How can I close the ...
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)?
58
votes
6
answers
66k
views
How do I print contents of at jobs?
I have a Debian box with some jobs scheduled using at. I know I can list the jobs with their times using atq, but is there any way to print out their contents, apart from peeking into /var/spool/cron/...
57
votes
4
answers
106k
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.
56
votes
6
answers
42k
views
Bash Loop - How to stop the loop when I press Control-C inside a command?
I am rsyncing a few directories. I have a bash terminal open and am executing something like this:
for DIR in * ; do rsync -a $DIR example.com:somewhere/ ; done
However if I want to stop the whole ...
56
votes
4
answers
289k
views
Is there a built-in command-line tool under Windows like wget/curl?
I come from a Linux/Unix background and I have been wondering if Windows has a binary that can download files from the console.
I would like to automate a certain process and one of my requirements ...
54
votes
10
answers
239k
views
How do I check the build status of a Jenkins build from the command line?
How do I check the Jenkins build status without switching to the browser?
If required, I can create a script using the JSON API, but I was wondering if there is already something like this built in.
54
votes
12
answers
137k
views
What are useful .screenrc settings?
Basically like some of my own that I've posted below. I'm looking for added functionality to the programme 'screen'. At the very least have a look at the last line for a fantastic 'menu bar' at the ...
52
votes
4
answers
107k
views
Linux/Windows/Unix/... file names: Which characters are allowed? Which are unescaped?
Which characters are allowed and which of them must be escaped on the command line in different operating systems?
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 -...
46
votes
3
answers
359k
views
How to check my PHP and MySQL version on Ubuntu VPS?
HI I am going to install MyBB but I am not sure whether I have installed the correct version of PHP and MySQL.
PHP version 5.1.0 or above with XML Extension installed
MySQL version 4.0 or ...
46
votes
3
answers
130k
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 -...
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.
44
votes
2
answers
11k
views
Using dot (.) as delimiter to specify group in chown
I've always done:
chown nimmylebby:admins file
I see that this also works:
chown nimmylebby.admins file
Might seem like a silly question but I'm genuinely curious on how the latter works. It isn't ...
43
votes
7
answers
249k
views
What is the windows command line command to copy files?
What is the windows command prompt command to copy files?
I need to move a file from location A to location B. Also if the folder for location B doesn't' exists I want to have it created.
I need ...
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 ...
42
votes
6
answers
43k
views
prevent xargs from quitting on error
According to the man page, xargs will quit if one of the execution lines exits with an error of 255:
If any invocation of the command exits with a status of 255, xargs will stop immediately without ...
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?
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 ...
41
votes
4
answers
38k
views
What's a secure alternative to using a MySQL password on the command line?
We have a PHP command-line script to version a database.
We run this script whenever a developer has added a new database patch.
The script runs the patch with the MySQL command-line:
system('mysql -...
40
votes
4
answers
158k
views
Get directory containing the currently executed batch script
I use %0 in batch file to get the containing directory of the batch file but the result is :-
c:\folder1\folder2\batch.bat
I want just directory, without batch file name, like this :-
c:\folder1\...