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 -lxlike above but sorted alphabetically.
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.
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.
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.
Copyright © 2004-2024 Katja Socher, tuxgraphics.org