Linux Command Line Cheat Sheet

To set the stage: what exactly is the command line? It’s basically a text-based interface that allows you to interact with your computer using commands instead of clicking around in fancy graphical user interfaces (GUIs). And let me tell ya, it can be pretty ***** useful for certain tasks especially if you need to automate something or do some serious data crunching.
So how does the Linux command line cheat sheet work? Well, it’s essentially a list of commonly used commands and their corresponding syntax (i.e., how to write them). And here’s where things get fun: instead of having to memorize all these commands or look them up every time you need them, you can just refer to the cheat sheet!
For example, let’s say you want to list all the files in a directory called “my_folder”. No problem just type this command into your terminal:

# This script lists all the files in a directory called "my_folder"
# The "ls" command is used to list files and directories
# The "my_folder/" argument specifies the directory to list

#!/bin/bash
# The above line specifies the interpreter to use for executing the script

ls my_folder/ # The "ls" command is used to list files and directories
# The "my_folder/" argument specifies the directory to list

You should see a list of all the files inside that folder. Pretty cool, right? But what if you want to do something more complex, like search for a specific file or delete it altogether? No worries just use some of these other handy commands:
– To search for a file called “my_file”, type this command:

grep -r -l -i -n "my_file" *.txt

This will look for the string “my_file” in all text files (i.e., those with the .txt extension) and print out any lines that contain it. Pretty handy!
– To delete a file called “my_other_file”, type this command:

ls # List all files in the current directory
rm my_other_file # Delete the file called "my_other_file"

And just like that, your file is gone forever (or at least until you hit Ctrl+Z and undo the action). But be careful once it’s deleted, there’s no going back!
– To create a new directory called “my_new_folder”, type this command:

# This script creates a new directory called "my_new_folder" using the mkdir command.

# First, we need to specify the bash interpreter to run the script.
#!/bin/bash

# Next, we use the mkdir command to create a new directory called "my_new_folder".
mkdir my_new_folder

# Finally, we add a comment to explain the purpose of the script.
# This script creates a new directory called "my_new_folder".

You should now have a brand spankin’ new folder to store all your files in. Pretty sweet, huh?
Of course, there are many more commands and options available for the Linux command line cheat sheet but these should give you a good starting point. And if you ever get stuck or need some help, just remember: Google is your friend!

SICORPS