On a Macintosh computer, many of the commands at the terminal are similar to those on Linux systems since macOS is based on a Unix derivative called Darwin. Here are some common commands and examples for Mac users:
ls
– List directory contents.
ls
cd
– Change the current directory.
cd ~/Documents
pwd
– Print the working directory.
pwd
mkdir
– Create a new directory.
mkdir new_directory
rmdir
– Remove a directory.
rmdir new_directory
touch
– Create a new, empty file.
touch new_file.txt
rm
– Remove files or directories.
rm new_file.txt
cp
– Copy files or directories.
cp source_file.txt destination_file.txt
mv
– Move or rename files or directories.
mv old_name.txt new_name.txt
cat
– Concatenate and display file content.cat file.txt
more
orless
– Display file content page by page.less file.txt
head
– Display the beginning of a file.head file.txt
tail
– Display the end of a file.tail file.txt
find
– Search for files in a directory hierarchy.find . -name "*.txt"
grep
– Search text using patterns.grep "search_term" file.txt
open
– Open files, directories, or URLs.open .
kill
– Terminate processes.kill 12345 # Where 12345 is the process ID
ps
– Report a snapshot of current processes.ps -ef
sudo
– Execute a command as another user (typically the superuser).sudo nano /etc/hosts
man
– Display the manual page for a command.bash man ls
These commands will help users navigate the filesystem, manage files and directories, view and search file content, manage processes, and obtain help while using the Terminal on a Macintosh computer.
which
– Shows the full path of shell commands.which ls
who
– Show who is logged on.who
whoami
– Print the user name associated with the current effective user ID.whoami
uptime
– Tell how long the system has been running.uptime
df
– Report file system disk space usage.df -h
du
– Estimate file space usage.du -sh *
top
– Display dynamic real-time view of a running system.top
clear
– Clear the terminal screen.clear
history
– Display the command history.history
date
– Display or set the system date and time.date
cal
– Display a calendar.cal
env
– Display, set, or remove environment variables.env
export
– Set an environment variable.export VAR_NAME=value
unset
– Unset an environment variable.unset VAR_NAME
alias
– Create an alias for a command.alias ll='ls -la'
unalias
– Remove an alias.unalias ll
curl
– Transfer data from or to a server.curl http://example.com
wget
– Non-interactive network downloader.wget http://example.com/file.txt
ssh
– OpenSSH SSH client (remote login program).ssh username@hostname
scp
– Secure copy (remote file copy program).bash scp file.txt username@hostname:/path
These additional commands cover a wide range of functionalities from managing environment variables, viewing system information, managing network connections, and much more. By mastering these commands, users can greatly enhance their efficiency and capability in handling various tasks on a Macintosh computer.
ping
– Test the reachability of a network host.ping google.com
traceroute
– Print the route packets take to a network host.traceroute google.com
netstat
– Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.netstat -an
ifconfig
– Configure network interface parameters.ifconfig
nslookup
– Query Internet name servers interactively.nslookup google.com
dig
– DNS lookup utility.dig google.com
ftp
– FTP client.ftp ftp.example.com
sftp
– Secure file transfer program.sftp username@hostname
nano
– Nano’s ANOther editor, an enhanced free Pico clone (text editor).nano file.txt
vim
– Vi IMproved, a programmers text editor.vim file.txt
chmod
– Change file modes or Access Control Lists.chmod 755 file.txt
chown
– Change file owner and group.chown username:groupname file.txt
chflags
– Change file flags.chflags uchg file.txt
tar
– Archive utility.tar -cvf archive.tar /path/to/directory
gzip
– Compress or expand files.gzip file.txt
gunzip
– Decompress files.gunzip file.txt.gz
zip
– Package and compress (archive) files.zip archive.zip file.txt
unzip
– List, test and extract compressed files in a ZIP archive.unzip archive.zip
screen
– Terminal multiplexer with VT100/ANSI terminal emulation.screen
tmux
– Terminal multiplexer.bash tmux
These commands help in network troubleshooting, file and directory permission management, text editing, file compression and archiving, and managing multiple terminal sessions among others. They are beneficial for system administration, network management, and everyday usage.
kill
– Terminate or signal a process.kill 12345 # where 12345 is the process ID
ps
– Report a snapshot of the current processes.ps aux
pgrep
– Look up or signal processes based on name and other attributes.pgrep -l bash
pkill
– Signal processes based on name and other attributes.pkill bash
lsof
– List open files.lsof
grep
– Print lines that match patterns.grep "pattern" filename
find
– Search for files in a directory hierarchy.find /path/to/directory -name filename
awk
– Pattern scanning and processing language.awk '{print $1}' filename
sed
– Stream editor for filtering and transforming text.sed 's/old/new/' filename
cut
– Remove sections from each line of files.cut -d':' -f1 /etc/passwd
sort
– Sort lines of text files.sort filename
uniq
– Report or omit repeated lines.uniq filename
diff
– Compare files line by line.diff file1 file2
head
– Output the first part of files.head -n 10 filename # outputs the first 10 lines of filename
tail
– Output the last part of files.tail -n 10 filename # outputs the last 10 lines of filename
xargs
– Build and execute command lines from standard input.find . -name "*.txt" | xargs rm
touch
– Change file timestamps.touch filename
cat
– Concatenate and print (or display) the content of files.cat filename
less
– Display file content page by page.less filename
more
– Display file content page by page (similar to less but less feature-rich).bash more filename
These commands cover aspects like process management, file searching, text processing, and viewing file contents among others. By learning these commands, users can perform a myriad of tasks on a Macintosh computer efficiently and effectively from the command line.
who
– Show who is logged on.who
w
– Show who is logged on and what they are doing.w
uptime
– Tell how long the system has been running.uptime
date
– Print or set the system date and time.date
cal
– Display a calendar.cal
df
– Report file system disk space usage.df -h
du
– Estimate file space usage.du -sh /path/to/directory
free
– Display the amount of free and used memory in the system.free -h
top
– Display Linux tasks (dynamic view of system processes).top
htop
– Interactive process viewer (advanced version of top).htop
alias
– Create an alias for a command.alias ll='ls -la'
unalias
– Remove an alias.unalias ll
history
– Display the command history.history
clear
– Clear the terminal screen.clear
exit
– Exit the shell.exit
ssh
– OpenSSH SSH client (remote login program).ssh username@hostname
scp
– Secure copy (remote file copy program).scp file.txt username@hostname:/path/to/directory
rsync
– A fast, versatile, remote (and local) file-copying tool.rsync -av /path/to/source-directory username@hostname:/path/to/destination-directory
curl
– Transfer data from or to a server.curl http://example.com
wget
– Non-interactive network downloader.bash wget http://example.com/file.zip
These commands help users to gather system information, manage disk space, create command aliases, and perform network-related tasks among others. By mastering these commands, users can control and interrogate their Macintosh system proficiently via the command line interface.