The cd command is used to change to another directory.
cd ..gets you one directory higher up.
lists all the files of the directory you are in
ls b*lists all files in the directory that start with b
ls *sun*lists all files in the directory that contain the string sun anywhere. However it won't find a string that contains Sun or sUn for example.
ls | grep -i raylists all files that include the string ray no matter if the individual letters are upper or lower case. That's very important if you search for a file and only remember that it contains a certain string but not how it was written.
ls -l *mars*shows you all files in your directory that contain the string mars with additional information. The output will show the permission rights, the size of the file, the last modified date and the name of the file.
ls -llists all files in the current directory in a long form with more informations (permission rights, the size of the file, the last modified date and the name of the file).
ls -lSThe S needs to be a capital letter. This lists all files in long form from biggest to smallest.
ls -ltlists all files in the current directory sorted by time, that is the files that were last modified are on top.
ls -lrtlists all files in the current directory sorted by time but as we put the r the order is reversed and the newest file, the file modifed last, is printed at the end. So the oldest files appear first and the newest files last.
The cp command is used to copy a file. Here file1 is copied into file2.
cp file1 stories/adventure/file2If file2 is in a different directory you need to specify the path to get there. Here the new file2 is saved under stories/adventure. You need to specify the relative path to get there. So it might be necessary to use ../../ or whatever relative path is needed to get there.
cp ../../stories/adventure/file2 .If you are in the directory where you need the new file you can also use the command above with the path as needed. The . tells linux to copy the file in the directory you are in right now.
If you want to copy a directory into another directory and keep all the subdirectories and files in it intact in the copy you go to the directory where the directory is, that is you go to the source directory. Let's say you want to copy directory dira which is in directory dirup. Then you go to directory dirup. There you type the above command and you are done.
Here is a breakdown of what each letter means:
cp: copy files/directories
-p: preserve file attributes such as permissions, ownership (where permitted), and timestamps
-r: recursively copy the directory and everything inside it
-n: do not overwrite files that already exist at the destination
-v: verbose; print what is being copied
This command is used to see if the content of 2 files is the same or what the differences are. If they are the same there is no output, otherwise the differences are listed.
mv stands for move and the command is used to rename a file. Here file1 will disappear and instead now be named file2.
with 1234 being the process ID of firefox (in this case). If your firefox has crashed once again and is hanging you first type the first command to get the process id. Then you type the second replacing 1234 with the actual ID. After that you can restart firefox. To use this command for any other application just replace fire with the appropriate name.
to create a new directory
remove (delete) a file
rmdirremove (delete) an empty directory
This command looks for files, not directories that contain the string andromeda, the -i makes it case insensitive
find . -type f | grep -i andromeda | grep -v DocumentsThis command looks for files, not directories that contain the string andromeda, the -i makes it case insensitive, the addition | grep -v Documents excludes the results that contain the string Documents
find . -mtime -2You can use the above command if you are looking for a file that you know you have modified within the last 2 days. Of course you could change the 2 into 1 or 5 for example to get the files you changed within the last day or the last 5 days respectively.
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -rYou can use the above command if you are looking for a file that you know you have recently modified. The command lists all files in the current directory ordered such that the most recently modified files are shown first.
Type date on the shell and you get the current date, starting with the day of the week, followed by the month, the day of the month, the time and the year.
Just typing cal returns the calendar for the current month.
cal 2022This returns the full calendar for the whole year.
cal 8 2021returns the calendar for August 2021.
cal aug 2021also returns the calendar for August 2021. You can also write August. It's not case sensitive. And the program only looks at the first 3 letters.
cal -m 5This returns the month, in this case May of the current year.
This gives you information on the cpu load and memory usage of the processes running on your computer sorted by cpu load. You can quit by typing q.
Typing this command in a shell and hitting return will take a screenshot of the screen. Many linux distributions come with it but unlike with the other commands you might need to install this first in case your distribution comes without.
For this imagemagick must be installed on your computer. If you have a text file that you want to convert into an image you first need to convert it to a pdf file. You can easily do this with libre office. With libre office click on "export as" and choose "export as pdf file", then type in the command line:
convert testpdf.pdf testjpg.jpg
with testpdf.pdf being the name of your textfile that you had converted into pdf and testjpg.jpg the name of your new image file.
stands for print working directory. Your shell can be configured in different ways. If you can't see the full path where you are in, then this command is very important to see where you actually are.
chmod stands for change mode. It is used to change the permission rights of a file or directory. The numbers represent specific permissions for the owner, the group and everyone else. For example, the 7 gives the owner full read, write and execute rights, while the first 5 gives people in the group read and execute rights only. The last 5 gives all others read and execute rights. chmod 700 file1 would only give the owner permissions to read, write and execute.
So the first number are your permissions, the second the permissions for a group and the third for everyone else. Then you should remember that
read = 4
write = 2 and
execute = 1
Adding them together gives you 7, meaning all three are allowed, 6 means you can read and write etc.
chown stands for "change owner". This command allows you to change the user ownership of a file or directory.
With the less command you can open a text file in an interactive, scrollable view. To move through the file page by page you can use the up and down arrow keys or the spacebar. To quit you type q which returns you to the shell.
more file1More is very similar to less. It shows you part of the content. By pressing thesSpacebar you can move down page by page or by pressing the enter key you can move down line by line. Again you need to type q to quit and return to the shell.
man stands for manual. You can use this to look up the meaning of commands, e.g. man ls, man cp etc. The manual usually explains what the command does, its options, and how to use it.
Copyright © 2004-2026 Katja Socher, tuxgraphics.org