Commands Flashcards
passwd
changes the current user password
echo
prints the text/string given to it to the screen, standard out, by default
-n
no new line
ls -d /*/
file structure and hierarchy that Linux implements to organize everything
pwd
“Print Working Directory” - This command tells you the path of the directory file you are navigating.
ls
“List Segments” - This command tells you what files are in the directory you are navigating. You can use the -a option to show hidden files. Hidden files in Linux start with a .
.
The . character represents the directory you are currently navigating.
..
This represents the directory that is directly above you.
cd
“Change directory” - This command takes an argument of a directory and puts you into that directory.
touch
creates a file in your working directory
mkdir
creates a directory in your working directory
mv
“Move” command takes two arguments:
The Source: The file you want to move.
The Destination: The location where you want to move the file.
use mv to rename files. Use the -r or “recursive” option to move an entire directory.
cp
“Copy” command also takes two arguments:
The source file to copy.
The destination location for the copy.
rm
delete files; if you would like to delete a directory and everything it contains, you can provide the -r or “recursive” option. This can be very dangerous, especially if you provide the -f or “force” option. You may end up accidentally deleting important files if you are not careful.
rmdir
“Remove Directory” is how to delete directories. This directory needs to be empty.
head
information from the head or top of a file
tail
pulls lines from the tail (bottom) of a file
sort
sorting the lines of a file
uniq
grabbing only the unique lines of a file. It is often useful to use with sort
wc
count of some input
>
redirects the STDOUT to a file and overwrites anything that may have been in the file previously
> >
appends the STDOUT to a file and appends the information to what was already in the file
|
edirects the STDOUT to another command. This is also called a “pipe”.
2> /dev/null
common addition to a command. Sometimes you do not want to see errors. Adding 2>
/dev/null will redirect STDERR so you do not see it
find
Find takes at least two arguments. The first argument is the directory you want to look inside. The second argument is what you are looking for in the file system. find has many options for finding based on size, name, and more.
locate
Locate works similarly to find. locate is generally the faster command. locate uses a database/cache to quickly store where a file is located. It is important to run the updatedb command often if you use locate so your database is up to date.
which
Which takes another command as an argument and will tell you where the binary for that command lives in the file system.
file
determining the type of a file
useradd
requires you to have already encrypted the password if you want password protection. This is a good command to use for scripting
adduser
tool for creating users
groupadd
analogous to useradd, which is better for scripting
addgroup
analogous to adduser, which is easier to use and set up a group
grep
grep -r ‘’ –> will search all directories & files starting from current directory
grep ‘’ – will search all files for search terms