Linux Commands On Mac Terminal Software

May 11, 2020  8 Best Kali Linux Terminal Commands for Hackers and Security Researchers (2020) Before we start telling you about the 8 best Kali Linux Commands for Hacking in the terminal, there are a few things we would like to discuss.Information provided in this article is for educational purpose only.If you plan to implement any of these commands, please be warned that things may get out of control.

Macos is Posix compliant, which means that if the Linux Commands are also Posix, then they will run on Macos as well. Assuming you meant “Linux Commands”, as to how to run them, this depends. Most command line commands in Linux will also. If you’re working in Terminal on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands. Folders are called directories in UNIX. Commands that refer to filenames, as most do, assume that you’re talking about files in the.

If you’re familiar with apt-get from Linux, then you know what a package manager does. It handles downloading, installing, updating and managing certain applications and their dependencies within the operating system. MacPorts is a command-line package manager for macOS. With MacPorts you can install Linux applications on macOS from the command line.

What can I install?

Most of these applications are open-source command-line utilities, but there are a fair share of GUI-based applications available as well. Applications like GIMP or GUI versions of command line utilities like diff can often be downloaded through MacPorts after a little exploring.

Here’s how it works: MacPorts hosts a collection of programs, called packages or “ports” in MacPorts parlance. Using a downloaded command line interface, you can search MacPorts’ library of software. When you find what you need, MacPorts downloads and installs the appropriate software and dependencies in the right places. This way, you don’t need to deal with opaque build instructions or confusing dependencies while still getting access to a wide range of the best and most powerful command line utilities.

Since macOS doesn’t come with many of the “standard” utilities included in most Linux distros, moving from Linux’s command line to macOS’ Terminal can sometimes be a let down. We can use MacPorts to install these missing commands, making the macOS command line nearly as capable as its Linux counterpart.

Installing MacPorts

Before you use MacPorts, you’ll need to install Xcode to gain access to a set of higher-end developer tools. These tools are required by many ports and packages, and by the MacPorts package manager itself. Xcode is an IDE made by Apple, and if you do much development, you likely already have it. If not, you can download Xcode from the Mac App Store or Apple’s developer website. You’ll need a developer account for the second option, so if you don’t have one, just go through the App Store.

While you can run most of the MacPort commands without Xcode, you won’t be able to run many of the packages until you install it. You also won’t get much of a warning, so things just won’t work, often without explanation.

Installing Xcode Developer Tools

Once Xcode is installed, you’ll need to install the Xcode developer tools. These are a separate set of command line utilities that many Terminal commands and ports rely on. Fortunately, it’s straightforward.

1. Open Terminal from /Applications/Utilities/Terminal.app

2. Use the command below to trigger the installation of macOS’ developer tools:

3. Click “Install” in the pop-up box to install the developer tools. If you don’t have Xcode, you can also click “Get Xcode” to install the application from here.

3. Wait for the files to download and install. It might take a while, so be patient and make sure you stay connected to the Internet.

Installing the MacPorts Package

Once Xcode is installed, you can move on to actually installing MacPorts. If you already have the Xcode and the developer tools installed, you can jump right to this step.

1. Download the latest release of MacPorts from GitHub. Make sure you scroll down to choose the version that matches your version of macOS. At the time of publication, there is no version of MacPorts for Apple’s newest OS, High Sierra, but one should be released soon.

2. Double-click and install the package from your Downloads folder.

Linux Commands On Mac Terminal Software

3. When you’re done with the installation, open a new Terminal window and run the command port.

If that command returns “MacPorts 2.4.x” and provides a slightly different-looking command prompt, then you’re ready to rock!

Install Linux Apps with MacPorts

To install some Linux apps on macOS with MacPorts, we will first need to search for the relevant programs.

Linux Commands On Mac Terminal Software

1. To see a gigantic list of all available packages, open Terminal, type port list and press Enter.

3. Obviously, that’s a lot to look through, and it wouldn’t be very efficient to scan it all. We can use the port search command to find something specific. Let’s search for the networking utility nmap using the command below:

4. That returns a few matching packages. It looks like many of them are extensions for nmap, which we’re not interested in. The first one, just called “nmap,” is the one we’re looking for.

5. To get more information about that package we can use the info command:

Get Mac Address Linux

Linux find mac address

6. That returns some specific information about nmap. That makes it pretty clear that this is the scanner we’re looking for. We can install with the command below:

Don’t forget that the sudo prefix which will require your admin password to fire. If you’re not logged in as an admin user, you’ll need to run the process again from an administer account.

7. Depending on the package you’re installing, there might be a large list of dependencies. These are software packages that your desired port relies on, and you’ll need to install them alongside your port of choice. Type “Y” and press “Enter” to accept the installation.

8. When the installation is complete, you can run the installed port as you would on Linux via Terminal.

Conclusion

You can check out an the awesome range of ports available by searching for tools you might like. You don’t need to restrict yourself to port names: any keywords will do. Poke around a little bit (port search image, for example) and you might find something unexpectedly useful.

Linux Find Mac Address

You might also like:

Update Mac Apps Using Terminal

Getting Started with Terminal: Adding New Commands with Homebrew

Getting Started with Terminal: Must-Know macOS Terminal Commands

If you’re working in Terminal on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands.

Linux Commands On Mac Terminal Software Download

Folders are called directories in UNIX. Commands that refer to filenames, as most do, assume that you’re talking about files in the working directory. When you open the Terminal window, the working directory is set to your home directory, abbreviated ~. Bash shows you the current working directory and your username to the left of its prompt. The following table lists common directory-related commands.

UNIX Directory Commands
CommandWhat It Does
lsLists the names of the files in the working directory. For more
complete information, use ls –alF (.
cd directorynameChanges the working directory to the one you named.
cd ..Brings you up one directory level.
cdReturns you to your home directory.
pwdDisplays the pathname of the current directory.
mkdir newdirectorynameMakes a new directory.
rmdir directorynameRemoves (deletes) an empty directory.

As in Windows, you can redirect the output of a command to a text file. So if you want a record of the files in a folder, type cd, followed by a space, drag the folder’s icon to the Terminal window, and press Return. Type ls > mydirectorylist.txt and press Return again. A file named mydirectorylist.txt will appear in the folder you chose. You can open the file in TextEdit to see a list of the files in that directory.

This table lists commands commonly used when working with files in the Terminal window.

Working with Files
CommandWhat It Does
cp filename1 filename2Copies a file.
chmodChanges permissions for access to a file. Study the man page
before using this one.
diffCompares two files line by line (assumes text).
more filenameDisplays a text file one page at a time. Press the spacebar to
see the next page; press Q to quit. The man command works through
more.
mv filename1 filename2Moves a file or changes its name.
rm filenameRemoves (deletes) a file.

This last table explains other handy commands that anyone getting started in Terminal will likely want to know.

Miscellaneous Commands
CommandWhat It Does
Control+CTerminates most operations.
dateDisplays the current date and time.
echoRepeats whatever appears after the command (after
expansion).
helpDisplays a partial list of bash commands.
historyDisplays the last commands you typed. You can redo a command by
typing an exclamation point (!) followed immediately (no space) by
the number of that command in the history list. To repeat the last
command, type !!. To repeat the last filename, type
!*.
picoA simple UNIX text editor.
psDisplays a list of running processes.
sudoLets you carry out commands for which the account you are using
lacks authority. You will be asked for an administrator’s
password.

When you’re working in Terminal, you don’t have a Trash Can to which deleted files are moved pending ultimate disposal. Delete it, and it’s gone. In general, UNIX has no Undo function.

Comments are closed.