I’d like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
Linux is just a kernel: a kernel is a component that talks to the hardware and manages resources. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!
cat prints or concats the content of files.
cd changes directory.
chmod is used to change permissions of files or directories.
chown is used to change the owner of files or directories.
cp is used to copy.
echo prints text
env run a program in a modified enviroment.
groups command prints a list of groups that a user belongs to.
kill is used to send signal or terminate a process.
ln is used to create links.
ls list files in a directory.
mkdir is used to create directory, absolutely useful.
mv is used to move or rename a file.
pwd command prints the current working directory.
rm removes file or directories.
su switches user or root.
sudo run as root.
touch creates an empty file, or update the atime of an existing file.
grep can be used to search text.
find can be used to search files.
fzf can be used to search files or make option menus. Unlike other tools in this list, it is not part of GNU Core utils or shell command line default tools, and is usually not installed by default.
We have already covered the basic usage of cat, cd, pwd, mkdir, chmod, chown, echo, ls, rm, groups.
We will begin an in-depth look at the remaining commands: cp, env, kill, ln, mv, su, sudo, touch, grep, find, fzf.
touchtouch is used to create an empty file, or update the atime and mtime of an existing file.
touch FILE # TOUCH it, create if not exist. If it exists, update the times.
cpcp is used to copy files or directories.
cp SOURCE DEST
cp SOURCE1 SOURCE2 ... DEST
cp -r SOURCE_DIR DEST
lnln is used to create links.
Hard link is a link to the inode of a file, there is only one file on your disk, but multiple names and paths pointing to it.
file —-> file_disk hardlink —-^
Symbolic link is a link to a path, like a shortcut in Windows.
a —-> file a itself is also a file.
ln SOURCE DEST # Create a hard link
ln -s SOURCE DEST # Create a symbolic link
mvmv is used to move or rename a file.
mv SOURCE DEST
envenv runs a program in a modified environment.
env VAR1=VALUE1 VAR2=VALUE2 COMMAND
A command is a function that takes input and produces output. The input to a command can be
Standard input (stdin)
Command line arguments
Environment variables
Output can be
Standard output (stdout)
Standard error (stderr)
Exit status
(stdin, arguments) ----command----> (stdout, stderr)
arguments
|
v
###############
stdin---> # # ---> stdout
# command #
# # ---> stderr
###############
Commands can be connected using pipes. The output of one command can be used as input to another command.
########
stdout # | # stdin of next command
---> # Pipe # --->
#######$
command1 | command2 | command3
############ ############ ############
stdin --> # command1 # -----> # command2 # -----> # command3 # --> stdout
############ ############ ############
grepgrep is extremely useful for searching text!
It can take input in stdin or from files (pass in file names as arguments). And it will filter out the lines that match the pattern.
grep PATTERN FILE
stdin | grep PATTERN
grep -Ir PATTERN DIRECTORY
grep -Irl PATTERN DIRECTORY
findfind is used to search files.
find DIRECTORY -type f -name "PATTERN" # Find files with name PATTERN in DIRECTORY
find . -type f ... -exec COMMAND {} \; # Execute COMMAND on each file foundfzfkill