35 Basic Linux Commands
However, the disk usage (du) summary will show disk block numbers instead of the usual size format. If you want to see it in bytes, kilobytes, and megabytes, add the _____ argument to the command line.
-h
What's more, using the ___ argument along with this command (locate command) will make it case-insensitive, so you can search for a file even if you don't remember its exact name.
-i
_______ (short for concatenate) is one of the most frequently used commands in Linux. It is used to list the contents of a file on the standard output (sdout). To run this command, type cat followed by the file's name and its extension. For instance: _________
1) cat 2)cat file.txt
Use the ______ command to copy files from the current directory to a different directory. For instance, the command __________________________ would create a copy of scenery.jpg (from your current directory) into the Pictures directory.
1) cp 2) cp scenery.jpg /home/username/Pictures
If you need to delete a directory, use the ______ command. However, ________ only allows you to delete ________________.
1) rmdir 2) empty directories
The arguments in mv are similar to the cp command. You need to type mv, the ______________, and ___________________.
1) the file's name 2) the destination's directory For example: mv file.txt /home/username/Documents.
Other variations when using the find are:
To find files in the current directory use, find . -name notes.txt To look for directories use, / -type d -name notes. txt
To search for a file that contains two or more words, use an
asterisk For example, locate -i school*note command will search for any file that contains the word "school" and "note", whether it is uppercase or lowercase.
creates a new file
cat > filename
joins two files (1 and 2) and stores the output of them in a new file (3)
cat filename1 filename2>filename3
to go straight to the home folder
cd
To navigate through the Linux files and directories, use the ____ command. It requires either the full path or the name of the directory, depending on the current working directory that you're in.
cd examples: 1) cd Photos 2) cd /home/username/Movies
to move one directory up
cd ..
to move to your previous directory
cd-
_______ is another Linux command, used to change the read, write, and execute permissions of files and directories.
chmod
In Linux, all files are owned by a specific user. The ________ command enables you to change or transfer the ownership of a file to the specified username.
chown For instance, chown linuxuser2 file.ext will make linuxuser2 as the owner of the file.ext.
Use ___ command to get a report on the system's disk space usage, shown in percentage and KBs. If you want to see the report in megabytes, type ___ -m.
df
Short for difference, the ______ command compares the contents of two files line by line. After analyzing the files, it will output the lines that do not match.
diff The simplest form of this command is diff file1.ext file2.ext
If you want to check how much space a file or a directory takes, the ___ (Disk Usage) command is the answer.
du
Similar to the locate command, using _____ also searches for files and directories. The difference is, you use the _______ command to locate files within a given directory.
find As an example, find /home/ -name notes.txt command will search for a file called notes.txt within the home directory and its subdirectories.
Another basic Linux command that is undoubtedly helpful for everyday use is _______. It lets you search through all the text in a given file.
grep To illustrate, grep blue notepad.txt will search for the word blue in the notepad file. Lines that contain the searched word will be displayed fully.
The _______ command is used to view the first lines of any text file. By default, it will show the first ten lines, but you can change this number to your liking.
head For example, if you only want to show the first five lines, type head -n 5 filename.ext.
You can use this command to locate a file, just like the search command in Windows.
locate
The ______ command is used to view the contents of a directory. By default, this command will display the contents of your current working directory.
ls
will list all the files in the sub-directories as well
ls -R
will show the hidden files
ls -a
will list the files and directories with detailed information like the permissions, size, owner, etc.
ls -al
Use ________ command to make a new directory — if you type ______ Music it will create a directory called Music.
mkdir
To generate a new directory inside another directory, use this Linux basic command
mkdir Music/Newfile
The primary use of the ________ command is to move files, although it can also be used to rename files.
mv
use the __ (parents) option to create a directory in between two existing directories.
p example: mkdir -p Music/2020/Newfile will create the new "2020" file.
pwd
print working directory
The ____ command is used to delete directories and the contents within them.
rm
Short for "SuperUser Do", this command enables you to perform tasks that require administrative or root permissions. However, it is not advisable to use this command for daily use because it might be easy for an error to occur if you did something wrong.
sudo command
This one has a similar function to the head command, but instead of showing the first lines, the ______ command will display the last ten lines of a text file.
tail For example, tail -n filename.ext.
The _____ command is the most used command to archive multiple files into a tarball
tar
This command is quite complex with a long list of functions such as adding new files into an existing archive, listing the content of an archive, extracting the content from an archive, and many more.
tar
a common Linux file format that is similar to zip format
tarball
The __________ command allows you to create a blank new file through the Linux command line. As an example, enter _____________ /home/username/Documents/Web.html to create an HTML file entitled Web under the Documents directory.
touch