This page contains just a teaser of some helpful commands. You should use man
or search for more information about the commands, e.g., what arguments and flags you can use to customize the command.
UNIX organizes permissions by user, group, and others. There are three different permissions available: read, write, and execute
chmod
is the command to change permissions
To change the group associated with a file, use chgrp
Gnu Regular Expression Print (grep
) is a helpful tool to search for text within files, using–you guessed it–regular expressions! Regular expressions can be quite simple.
Example: I want to find all the names that start with “Sara” in a file of names
grep Sara names.txt
You can find files with various characteristics using the find
command. It will look in the directory specified and all of its subdirectories. You can then apply a command to those found files.
Examples:
Find all of the files with the .txt extension in the current directory and its subdirectories
find . -name "*.txt"
Find all of the files in my home directory (and its subdirectories) that have no data in them (have 0 Bytes of data)
find ~ -size 0
View all of the information (e.g., last modified date) of all of the files in my home directory (and its subdirectories) that have no data in them
find ~ -size 0 -exec ls -l {} \;
Usage:
head <filename>
shows the first few lines of a file. You can use a flag to change how many lines are displayed
lsof -i :<port>
e.g.,
lsof -i :8080