Questions tagged [command-line]

Using programs and commands that do not have a graphical user interface (GUI) but are rather controlled by typing text commands into a terminal program, or shell.

Filter by
Sorted by
Tagged with
338
votes
11answers
176k views

git auto-complete for *branches* at the command line?

On my Linux machine I have autocomplete for branches with Git. [Note we are talking about git branch completion, not bash completion (e.g. commands, files, etc). Thus NOT Lane's answer at all] For ...
301
votes
12answers
170k views

How can I trigger a Notification Center notification from an AppleScript or shell script?

I'd love to be able to take advantage of 10.8's Notification Center features in AppleScripts and shell scripts I write. Is there a built-in command or a third-party library I can use from either an ...
240
votes
4answers
186k views

What is the difference between .bash_profile and .bashrc?

To make an alias for the Terminal in OS X, you can either put the aliases in .bash_profile or .bashrc. What is the difference between the two and why would I choose to put aliases in one and not the ...
195
votes
13answers
359k views

Why doesn't .bashrc run automatically?

I put some alias commands in my .bashrc file, so that they might be loaded everytime I open a new Terminal window. Yet this doesn't happen. I have to select run script: in the Terminal>Preferences>"...
191
votes
21answers
225k views

Is there a Mac OS X Terminal version of the “free” command in Linux systems?

On Linux, I often use the free command to see the current amount of free and used memory in the system. For example: $ free total used free shared buffers cached ...
164
votes
5answers
314k views

Can I open files in TextEdit from the Terminal in Mac OS X?

I frequently find that a Terminal command to open a file in TextEdit would be very handy. Does such a command exist on Mac OS X?
161
votes
1answer
210k views

How do I launch Finder from terminal or command line [duplicate]

I use command line a lot, like most programmers. I want to be able to launch Finder, Safari or any other application for that matter from command line e.g. finder . where it will start Finder ...
148
votes
10answers
132k views

What is the difference between iTerm2 and Terminal?

I keep hearing that iTerm2 is much better than Terminal. However, when I downloaded iTerm2, I didn't see what made it preferable over Terminal. What are the differences between these two apps?
146
votes
8answers
65k views

iTerm - going one word backwards and forwards

Would it be possible to configure iTerm 2 to go backwards and forwards one word through the curent text in the command line using a keyboard shortcut?
127
votes
14answers
58k views

How to move files to trash from command line?

I do a lot of terminal work, and today had the experience of typing rm fileInQuestion.txt Before finding out that I did actually need fileInQuestion.txt. If I'd deleted in the GUI then I would have ...
124
votes
6answers
216k views

Can I get the CPU temperature and fan speed from the command line in OS X?

Is there a command I can run from the command line in OS X to get the current CPU temperature and/or the fan speed(s)? To be more specific, I'd like to be able to get the same info available in the ...
121
votes
5answers
66k views

Need a cli to check the sha256 hash of a file

To check the sha1 of a file I would use openssl sha1 <file> I'm not sure what to use to check the sha256 hash of the file however, what would you recommend?
93
votes
10answers
36k views

How do I speed up new Terminal tab loading time?

How can i speed up the terminal startup in Lion? I'm not referring to the startup of the Terminal application, but to the startup terminal windows, like when i open a new tab. I don't have anything ...
93
votes
2answers
151k views

Why doesn't Mac OS X source ~/.bashrc? [duplicate]

I found a lot of people figuring out why instruction similar to this : Put X to your ~/.bashrc and you can do Y don't work. It always turns out that Mac OS X's bash's startup files (or Mac's Bash ...
83
votes
5answers
46k views

Linux' `ps f` (tree view) equivalent on OSX?

How can I get a tree view like the one below on OSX? vartec@some_server:~$ ps xf PID TTY STAT TIME COMMAND 11519 ? S 0:00 sshd: vartec@pts/0 11520 pts/0 Ss 0:00 \_ -bash ...
82
votes
2answers
250k views

List all devices connected, lsblk for Mac OS X

In Linux if I want to see all the devices currently connected to my computer in the command-line, I run: lsblk or blkid What's the equivalent command under Mac OS X? NOTE The goal here is ...
77
votes
5answers
345k views

How do I run a .sh or .command file in Terminal

I've always wanted to be able to run a script I've downloaded online directly from the Finder but just double clicking the file does not work.
75
votes
5answers
50k views

Update bash to version 4.0 on OSX

Is it possible to actually update bash to version 4.0 in OSX Yosemite? echo $BASH_VERSION 3.2.57(1)-release This article and this thread refer to the same question, but they install a new shell side-...
73
votes
11answers
48k views

Can home and end keys be mapped when using Terminal?

The home and end keys on a MacBook Pro can be emulated with fn + left arrow or fn + right arrow. Or when certain settings are changed, with the Command (Apple) key instead of fn. None of these ...
73
votes
7answers
217k views

How can I list all user accounts in the terminal?

How can I list all local user accounts in Terminal (whether logged in or not?) The commands users or who does not provide this information. OS X version is 10.6.8. I have seen this suggested command -...
71
votes
19answers
142k views

Password dialog appears when SSH private key permissions are set to 0600

I installed my SSH private key in ~/.ssh/id_rsa and set its permissions to 0600. When I connect to an SSH server which uses my private key in Terminal.app via ssh, a dialog pops up and asks me to ...
68
votes
3answers
411k views

How to open files via Terminal

I want to open videos and pictures from Terminal. Is there any way to do this?
64
votes
8answers
240k views

How do I start TextEditor from the command line?

I work a lot at the command line in a Terminal and would like to start a text editor on a certain file. I'm from Linux Land and normally use kwrite or gedit from a bash shell. Trying to find the Mac ...
60
votes
15answers
46k views

How to get a notification when my commands are done

I'm running a series of commands on the command line that takes approximately twenty minutes to complete. I'd like to see some sort of notification on my Mac when these are finished so I don't need ...
59
votes
18answers
40k views

Lock Screen Command One-Liner

I'm trying to find out whether there is any kind of equivalent command line one-liner which replicates the exact identical functionality of the 'Lock Screen' menu option available via the Keychain app ...
58
votes
6answers
62k views

How to get BSD FTP and Telnet back in 10.13 (High Sierra)?

There are some real problems with not having ftp and telnet present in 10.13 now as per Apple's dictate. Has anyone found a solid way to bring BSD ftp and telnet back to macOS vs using inetutils?
57
votes
7answers
73k views

How can I unpack .7z files via MacOS terminal?

Looking to unpack a bunch of files.7z via terminal. Is there a command-line tool built in, available or I shall install an application that comes with a graphical interface?
54
votes
2answers
60k views

Run AppleScript from bash script

If I wanted to run an AppleScript from within a bash script I could call a file with the list of commands that I require to execute. #!/bin/bash {some commands} osascript file.scpt {other commands} ...
51
votes
10answers
27k views

How can I change a file or folder icon using the Terminal

How can I change or set the icon for a file or folder, in the terminal, do I need to use a scripting language?
50
votes
5answers
79k views

Is there a command to install a dmg

I want to install a dmg file on a remote server. All I have is an ssh access. Since a DMG is a disk image, I tried to mount it, but mount does not seem to recognize its format. file says my dmg file ...
47
votes
2answers
56k views

How can I display the current DNS servers from the command line under OS X?

I want to display the DNS servers that are used by the current network setup on OS X, from the command line.
46
votes
5answers
13k views

Is there a way to access a Mac's geolocation from terminal?

Some GUI apps use OS X location services, but I want to retrieve a Mac's physical location from the command line. This could be useful for running scripts, switching settings etc. The mechanism should ...
46
votes
2answers
8k views

Where should I store command line applications?

When I download command line applications they are located in my ~/Downloads/ directory. But I feel this is wrong place to have a command line application located. Where in the Mac OS X filesystem ...
46
votes
7answers
68k views

How to always show menubar with fullscreen apps?

Does anyone know if it is possible to keep the menubar in Mac OS Lion visible for fullscreen apps instead of hidden until hovered over with a mouse or trackpad? I imagine there's some Terminal ...
45
votes
4answers
35k views

Install shuf on OS X?

Ubuntu Linux has a great tool called shuf, which works like head except that it gives you ten random lines. I couldn't find it on Homebrew. What is the simplest way of installing it on OS X?
43
votes
5answers
27k views

How can I combine multiple PDFs using the command line?

Is there a quick one-liner to combine multiple pdfs into one? I know it can be done using Preview.app
42
votes
5answers
10k views

Homebrew and Git - Wrong language on the command line

I have a strange issue - when I use the git command which comes with the Command Line Tools package, the interface on the command-line is in English, as I want it to be. However, the version installed ...
40
votes
7answers
30k views

How can I install the Command Line Tools completely from the command line?

I'd like to script the installation of the the Xcode Command Line Tools. On Mavericks, xcode-select --install will open a dialog prompting the user to install, but I'd like to trigger the install ...
39
votes
4answers
23k views

MacPorts vs. Fink vs. Homebrew [duplicate]

I always used MacPorts to install and maintain my GCC compilers and other programs. Now I've heard about Fink and Homebrew. It seems these two utilities are gaining ground in the Mac community, but I ...
38
votes
9answers
38k views

What directory comparison tools can I use on OS X?

I am looking for a tool that is able to compare directories, not only files. Also it is important to be able to call the tool from the command line. It would be great to have a free tool, if not free ...
37
votes
6answers
25k views

How can I track progress of dd

I am using the following command to create a bootable SD Card sudo dd bs=4m if=en_windows_10_enterprise_version_1511_x64_dvd_7224901.iso of=/dev/disk2 Is there a way to track the progress?
36
votes
3answers
25k views

How do I reset the scrollback in the terminal via a shell command?

When using Terminal.app, you can clear the screen by using the shell builtin clear or by pressing ^+L (Control-L). However, all this does is push the current screen content back one screen height ...
36
votes
4answers
51k views

How can I find the serial number on a mac programmatically from the terminal?

What command can I use to retrieve the system's serial number from the unix command line? As uname will output some information about the software and hardware, I would like to retrieve the serial ...
36
votes
4answers
15k views

Can running `yes > /dev/null` harm a Mac?

I recently ran yes > /dev/null for a 3 minutes to drain my Mac's battery. During that time, the temperature rose to 72 °C and fans spun up to 4000 RPM. I immediately quit the process. Should I ...
34
votes
3answers
10k views

Why is lsof on OS X so ridiculously slow?

I can't figure out why lsof on my Mac (10.8.2, MacBook Pro) is so slow. On my Mac, lsof takes more than a minute: $ touch /tmp/testfile $ time lsof /tmp/testfile real 1m16.483s user 0m0.029s ...
28
votes
7answers
60k views

How to send an email from command line?

How to send an email from command line or script? I want to be able to run the script programmatically by passing the receiver and the message.
28
votes
4answers
10k views

Can Mac App Store installs & upgrades be automated?

How can I script installing or upgrading apps from the Mac App Store? I'd prefer command line tools, but AppleScript or some other API would suffice. Relevant puzzle pieces: installer: note ...
27
votes
5answers
5k views

Did `man ls > temp.txt`. Output textfile is corrupted

When I execute man ls > temp.txt the output text file is corrupted. By corrupted I mean that first and last letters in some words are overly repeated. Several first lines in temp.txt: LS(1) ...
27
votes
6answers
96k views

How to add MySQL to $PATH variable to resolve “mysql: command not found”?

I installed MySQL on my Mac, and now I would like to add it to my $PATH variable. I want to be able to type mysql anywhere. I tried adding the following to my .profile file: export PATH=${PATH}/usr/...
27
votes
5answers
29k views

How do I take a steathy picture with my iSight camera from the command line?

Is there a command line utility that allows me to take a picture from the built in camera? Something like screencapture allows for, well, screen captures. The reasoning for a command line tool is I ...