Unix is an operating system originally designed by Dennis Ritchie and Ken Thompson at Bell Labs in the 1960s and has since evolved into various flavors, including Linux. It is known for its multi-user and multitasking capabilities, as well as its portability and stability.
Here is an interesting video that shows the creators of this language describing it:
https://www.youtube.com/watch?v=XvDZLjaCJuwIn essence Unix has these concepts and components:
Kernel: The kernel is the core of the Unix operating system. It manages hardware resources and provides essential services, such as process scheduling, memory management, and device drivers. The kernel is responsible for maintaining system integrity and ensuring that user programs can run efficiently.Shell:
Shell: The shell is a command-line interface that allows users to interact with the operating system. It interprets user commands and communicates with the kernel to execute those commands. Unix shells come in various flavors, with Bash (Bourne Again SHell) being one of the most popular. Utilities:
Utilities: Utilities are small, specialized programs that perform specific tasks. Unix provides a rich set of utilities that can be combined to achieve more complex operations. Examples include ls for listing files, cp for copying files, and grep for searching through text.
Users: Unix is a multi-user system, meaning that multiple users can interact with the system simultaneously. Each user has their own account and home directory, which contains their files and configurations. Users are identified by unique usernames.
Command | Description | Example |
---|---|---|
ls | List files and directories | ls |
cd | Change directory | cd /path/to/directory |
pwd | Print working directory | pwd |
cp | Copy files or directories | cp file1.txt file2.txt |
mv | Move or rename files or directories | mv file1.txt new/location/file1.txt |
rm | Remove files or directories | rm file.txt |
mkdir | Make directory | mkdir new_directory |
echo | Output text to the terminal | echo "Hello, Unix!" |
grep | Search for a pattern in files | grep "pattern" file.txt |
cat | Concatenate and display file contents | cat file.txt |
man | Display manual or help documentation for a command | man ls |
chmod | Change file permissions | chmod +x script.sh |
chown | Change file owner and group | chown user:group file.txt |
ps | Display information about processes | ps aux |
kill | Terminate a process | kill process_id |
top | Display real-time system statistics | top |
df | Show disk space usage | df -h |
du | Show disk usage | du -h |
tar | Archive and compress files | tar -cvf archive.tar files/ |
gzip | Compress files | gzip file.txt |
gunzip | Decompress files compressed with gzip | gunzip file.txt.gz |
ssh | Connect to a remote server securely | ssh user@remote_host |
scp | Copy files securely between hosts | scp file.txt user@remote_host:/path/to/destination/ |
wget | Download files from the internet | wget https://example.com/file.txt |
curl | Transfer data to or from a server | curl -O https://example.com/file.txt |
find | Search for files and directories | find /path/to/search -name "*.txt" |
locate | Quickly find the location of files | locate file.txt |
history | Display a list of previously executed commands | history |
alias | Create a shortcut or alias for a command | alias ll='ls -l' |
head | Display the first few lines of a file | head -n 5 file.txt |
tail | Display the last few lines of a file | tail -n 10 file.txt |
sort | Sort lines of text files | sort file.txt |
uniq | Filter adjacent matching lines from a sorted file | uniq file.txt |
wc | Count lines, words, and characters in a file | wc file.txt |
diff | Compare the contents of two files | diff file1.txt file2.txt |
vim or nano | Text editors for creating or editing files in the terminal | vim filename |
date | Display the current date and time | date |
cal | Display a calendar for the current month or year | cal |
echo | Display text or a variable | echo "Hello, World!" |
alias | Show a list of defined aliases | alias |
unalias | Remove an alias | unalias ll |
uptime | Show how long the system has been running | uptime |
who | Display information about users currently logged in | who |
w | Display information about currently logged-in users and their activities | w |
id | Show the user and group information for the current user | id |
groups | Display the groups a user belongs to | groups |
su | Switch to another user | su username |
sudo | Execute a command with superuser privileges | sudo command |
passwd | Change the user password | passwd |
ifconfig | Display network interface configuration | ifconfig |
awk | Versatile text processing tool | awk '{print $2}' file.txt |
sed | Stream editor for text filtering | sed 's/old_pattern/new_pattern/' file.txt |
tr | Translate or delete characters | echo "Hello" | tr 'a-z' 'A-Z' |
basename | Strips directory and suffix from filenames | basename /path/to/file.txt |
dirname | Strips non-directory suffix from filenames | dirname /path/to/file.txt |
file | Determines file type | file myfile |
ln | Creates hard or symbolic links | ln -s source_file link_name |
tee | Reads from standard input and writes to standard output and files | echo "Hello" | tee output.txt |
env | Displays or sets the environment variables | env |
export | Sets environment variables | export PATH=$PATH:/new/directory |
trap | Sets up signals to be caught and processed during script execution | trap 'echo "Caught signal"' SIGINT |
diff | Compares the contents of two files | diff file1.txt file2.txt |
# Create a symlink for the airpot utility
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
# Sniff traffic on a channel with some interface
# syntax:: airport [interface] sniff [channel]
sudo airport en1 sniff 1
sudo airport en0 sniff 9
# netowrk connections list
networksetup -listallhardwareports
# Enable or Disable WIFI
networksetup -setairportpower en0 on
networksetup -setairportpower en0 off
# Join Wi-Fi network
networksetup -setairportnetwork en0 SSID PASSPHRASE
# Create a Wi-Fi network profile
networksetup -addpreferredwirelessnetworkatindex en0 SSID_OF_NETWORK INDEX_NUMBER SECURITY_OF_WIRELESS_NETWORK WIRELESS_NETWORK_PASSPHRASE
# Delete a Wifi network profile
networksetup -removepreferredwirelessnetwork en0 SSID_OF_NETWORK
# Remove all stored wifi network profiles
networksetup -removeallpreferredwirelessnetworks en0
# Show path in finder
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
# List all the usb devices currently plugged in
ioreg -p IOUSB
ioreg -p IOUSB -w0 -l
# List just the device names
ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*'
# show processes that are using a specific port (Eg 3000 ) do :
lsof -i :3000