Basic Linux Commands

Introduction

Since the inclusion of Bash on Windows, I’ve been blessed with the awesome Bash commands. Today, I go over the most useful commands I’ve used in Linux to date after just starting out. Note, these are just commands I’ve learned after starting to use Linux.

touch

“touch” is one of the most useful commands I’ve used. “touch” creates a file if it doesn’t exist, otherwise it updates the timestamps on each touched file. Here’s an example of touch command structure: touch file.txt or touch file.js . Command structure: touch filename1 filename2 The best part is you can make any file you want from the command line, even ones that don’t have file extensions.

mv

“mv” or move, lets you move files around on the computer. Now, you could do that in your file explorer, but “mv” and many other commands let you perform operations on files based on file extensions or similar file names. Here’s an example of each respectively: mv *.js js/plugins, mv *todo* todo/

The command structure is:  mv filename path. The first example moves all “.js” files to the plugins folder. The next examples all files with “todo” in their name to the todo folder. Now, let’s talk about “rm”.

rm

“rm” or remove, can delete files or directories permanently(they don’t even go in the recycle bin). This command is helpful when I place files in the wrong directory or want to remove a whole directory structure. Here’s an example of both respectively: rm File1.txt and rm -r js/plugins

These are just two examples; The first example removes File1.txt and the second removes the js/plugins directory. rm can also use regular expressions to delete many files with a certain extension, or word in their names.

ln

“ln” is a command that allows you to create links on your computer. The easiest way to think of them is like a shortcut on a Windows computer. The only form of command I’ve used is the soft link form. Here’s an example: ln -s images/specialimages/ spimages
With that command, I’ve created a soft link to the specialimages folder called spimages. Now, that’s only one use; you can also create links to files and executables. There are many possibilities.

cp

“cp” is the last command on today’s list and it allows you to copy files and directories. This is a useful command when you simply want to copy a group of files to a directory you just made. Here’s an example: cp *.js js/plugins_cpy This will copy all the files within the current directory with the “.js” extension to the js/plugins_cpy folder.

Now, I hope these commands help you Linux enthusiasts that are getting started. To all of you experienced users, please share other cool commands below that could help others and myself.

Leave a Reply

Your email address will not be published.