If you’re breaking into the world of Linux from Windows or Mac, you’ll find it’s a much more hands-on platform and getting to grips with Linux commands is essential.
Here are our top commands you need to know in order to view file listings in a folder, add new files and folders and delete them again.
The first command you’ll need to know if you fancy yourself as a Linux whizz is the ‘is’ command. This represents the list command and will present to you all items in a given file system. For example, typing is/applications into the Linux terminal will present you with a list of all the applications installed in your applications folder. Type in is followed by / and any folder on your device to see what’s in each folder or directory.
cd is the change directory and typing this command into the Linux terminal will allow you to switch from the current directory you’re working in to another. To use the command, type in cd followed by the /, then the directory you want to go to, including the entire pathname.
If you want to head straight to the home directory, you can simply input cd ~ to be taken straight to the home directory.
mv is the command for move and using this line instructs the system to move files from one directory to another. The first string of commands will locate the file to be moved, while the second will instruct Linux where to move it to.
An example would be: mv/mydoc/documents /mydoc/work which would move the mydoc file from the documents folder to the work folder.
If you want to create a new directory, use the mkdir command. Just type in mkdir followed by the new directory name, for example mkdir newdirectory and the newdirectory will be created on your Linux device.
As you’ve probably guessed, rmdir tells the Linux system to remove a particular directory. Just like mkdir, you simply have to type in rmdir with the directory name, for example “rmdir newdirectory” and newdirectory will be removed from the system.
You will not be able to delete any directories with files or other directories in it. To do this, you will need to remove the files or sub-directories first.
To remove files, you’ll need to use the rm command, followed by the file name. If you want to remove a directory with files in it, type in rm followed by the directory name.
Touch is the command for making new files within directories. To make use of the touch command, simply type in “touch docname.extension” to create that file type in the current directory. For example, touch textfile.txt will create an empty text file named textfile.
locate will help you find files and directories wherever they may be on your Linux system. This is where the command lines start to get a little complicated, because there are a number of parameters you can implement to find a specific file, or one containing any number of words, in upper or lower case.
The easiest (but unfortunately, laziest) way of locating a file is by using locate, followed by -i, which tells the system to search using either upper or lower case and then the words you’re looking for with and asterisk before and after each word.
For example, if you’re looking for a file that contains the words “accounts 2016 2017”, you would type in locate -i *accounts**2016**2017 and up will pop a list of the files with matching words.
Had enough of a messy command line interface? Just type in clear and everything will magically disappear, allowing you to start with a clean slate again.
This article originally appeared at itpro.co.uk