The Description for the most commonly used Linux basics commands is given below inan alphabetic order.Description for the most commonly used Linux basics commandsa) catcat allows you to read multiple files and then print them out. You can combinefiles by using the > operator and append files by using >>.Syntax: cat [argument] [specific file]Example:cat abc.txtIf you want to append three files (abc.txt, def.txt, xyz.txt), give the commandas,cat abc.txt def.txt xyz.txt > allDescription for the most commonly used Linux basics commandsb) cd, chdircd (or chdir) stands for “change directory”. This command is the keycommand to move around your file structure.Syntax: cd [name of directory you want to move to]When changing directories, start with / and then type the complete file path, likecd /vvs/abc/def in this eg. You are moving from vvs directory to abc directory then move todef directory . You can also move relative to the current directory by typing cd vvs/abc/defTo move relative to the parent directory of your current directory, useCd ../vvs/abc/defc ) chmodchmod (which stands for “change mode”) changes who can access a particularfile. A “mode” is created by combining the various options from who, opcode,and permission.Syntax: chmod [option] mode fileIf you look at a list of files using the long list command ls “l, you’ll see thepermissions, owner, file size, modification time, and filename. The firstcolumn of the list shows who can read, write, and execute the files ordirectories, in other words, the permissions. It basically shows who haspermission to do what to a given file or directory. r stands for “read” andmeans that you’re allowed to read the file or directory. w stands for “write”and gives permission to edit or change the file as well as create, move,rename, or remove a directory. x stands for “execute” which givespermission to run a file or search a directory. Every file or directory has four sets of rwx permissions.The first set represents the user (u), the second set represents thegroup (g), the third set represents other (o), and the fourth set represents all(a). The column will look like this: rwxrwxrwxEach set of rwx represents user, group, and other respectively. Only the ownerof a file or a privileged user may change the permissions on a file. There aretwo ways to change permissions on a file or directory, either numerically orby using lettered commands. Both ways use the command chmod. To addpermissions to a file, you use +, to remove permissions you use-.For example, take a file:-rw-r”r” 1 yash mony 6 Apr 14 17:13 vvs.txtTo allow a group (mony, in this case) “write” access, you would type:chmod g+w vvs.txtIf you wanted to remove “read” ability from “other” you would type:chmod o-r vvs.txtIt is also possible to specify permissions using a three-digit sequence. This is amore efficient way to change permissions (or at least it requires less typing),so use this method if it doesn’t confuse you. Each type of permission is givenan octal value. Read is given the value of 4, write is given the value of 2, andexecute is given the value of 1. These values are added together for each usercategory. The permissions are changed by using a three-digit sequence withthe first digit representing owner permission, the second digit representinggroup permission, and the third digit representing other permission. Forexample, if you wanted to make vvs.txt readable, writable, and executable forthe user, readable and writable for the group, and readable for other, youwould type: chmod 764 vvs.txtThe first digit means readable and writable for the user (4+2+1), the seconddigit means readable and writable for the group (4+2+0), and the third digitmeans readable for other (4+0+0). if you want to change the permissions on adirectory tree use the -R option. chmod “R will recursively change thepermissions of directories and their contents.Description for the most commonly used Linux basics commandsd) cpThe cp command copies files or directories from one place to another. Youcan copy a set of files to another file, or copy one or more files under the samename in a directory. If the destination of the file you want to copy is anexisting file, then the existing file is overwritten. If the destination is anexisting directory, then the file is copied into that directorySyntax: cp [options] file1 file2 If you want to copy the file favourites.htmlinto the directory called laksh, you givethe command as:cp favourites.html /vvs/laksh/A handy option to use with cp is -r. This recursively copies a particulardirectory and all of its contents to the specified directory, so you won’t haveto copy one file at a time.e) dateThe date command can be used to display the date or to set a date. In unix theterm date includes the time as well.Syntax: date [option] [+format]date [options] [string]The first structure shows how date can be used to display the current date. Acertain format can be specified in which the date should be displayed. Checkthe Unix manual for specific formats and options. The second structureallows you to set the date by supplying a numeric string. Only privileged userswill be able to use this second command structure.Description for the most commonly used Linux basics commandsf) diffdiff displays the lines that differ between two given files.Syntax: diff [options] [directory options] file1 file2diff can be an extremely valuable tool for both checking errors and buildingnew pages. If you run a diff between two files, you’ll be shown whatdifferences the files have line by line. The lines referring to file1 are markedwith the symbol. Ifthe file is a directory, diff will list .the file in the directory that has the samename as file2. If both of the files are directories, diff will list all the linesdiffering between all files that have the same name. If you have a file that isnot working properly, it can be a great help to check it against a similar filethat is working. It will often quickly alert you to a line of code that’s missing.A handy option to use if you want to generally compare two files withoutnoting the complex differences between them is the -h option (h stands forhalf-hearted). Using -i as an option will ignore differences in uppercase andlowercase characters between files, and -b will ignore repeating blanks andline breaks.Description for the most commonly used Linux basics commands(g) exitThe exit command allows you to terminate a process that is currentlyoccurring. For example, if you wanted to leave a remote host that you werelogged onto (see rlogin also), you should type exit. This would return you toyour home host.h) findfind searches through directory trees beginning with each pathname and findsthe files that match the specified condition(s). You must specify at least onepathname and one condition.Syntax: find pathname(s) condition(s)There are several handy conditions you can use to find exactly what you want.The -name condition will find files whose names match a specified pattern.The structure for the name condition is: find pathname -name patternThe condition -print will print the matching files to the pathname specified. “printcan also be used in conjunction with other conditions to print the output.If you wanted to find all the files named favorites.html in the directory Ram, thenyou’d do this: find /Ram -name favorites.html “printThis looks through the directory Ram and finds all the files in that directorythat contain favorites.html, then prints them to the screen. Your output wouldlook like this:/Ram/sixteen_candles/favorites.html/Ram/favorites.html/Ram/breakfast_club/favorites.htmlAll meta-characters (!, *, ., etc.) used with -name should be escaped (place a before the character) or quoted. Meta-characters come in handy when you aresearching for a pattern and only know part of the pattern or need to findseveral similar patterns.For example, if you are searching for a file that contains the word “favorite”,then use the meta-character * to represent matching zero or more of thepreceding characters. This will show you all files which contain favorite.find /Ram -name ‘*favorite*’ -printThis looks through the directory Ram and finds all the files in that directorythat contain the word “favorite”. The output would look like this:/Ram/sixteen_candles/favorites.html/Ram/favorites.html/Ram/least_favorites.html/Ram/breakfast_club/favorites.html/Ram/favorite_line.htmlThe -user condition finds files belonging to a particular user ID or name.Description for the most commonly used Linux basics commandsi) grepThe grep command searches a file or files for lines that match a providedregular expression (“grep” comes from a command meaning to globallysearch for a regular expression and then print the found matches).Syntax: grep [options] regular expression [files]To exit this command, type 0 if lines have matched, 1 if no lines match, and 2for errors. This is very useful if you need to match things in several files. Ifyou wanted to find out which files in our vvs directory contained the word“bca” you could use grep to search the directory and match those files withthat word. All that you have to do is give the command as shown:grep ‘bca’ /vvs/*The * used in this example is called a meta-character, and it representsmatching zero or more of the preceding characters. In this example, it is usedto mean “all files and directories in this directory”. So, grep will search all thefiles and directories in vvsand tell you which files contain “bca”.Description for the most commonly used Linux basics commandsj) headDisplays the first ten lines of a file, unless otherwise stated.[-n] [files]Syntax: headFor example, the following command will display the first 15 lines offavourites.html.head -15 favourites.htmlDescription for the most commonly used Linux basics commandsk) killkill ends the execution of one or more process ID’s. In order to do this youmust own the process or be designated a privileged user. To find the processID of a certain job give the command ps.Syntax: kill [options] PIDsThere are different levels of intensity to the kill command, and these can berepresented either numerically or symbolically. kill -1 or HUP makes arequest to the server to terminate the process, while kill -9 or kill KILL forcesa process to terminate absolutely. Most politely, UNIX users will attempt tokill a process using-1 first before forcing a process to die.Description for the most commonly used Linux basics commandsl) lss will list all the files in the current directory. If one or more files are given,ls will display the files contained within “name” or list all the files with thesame name as “name”. The files can be displayed in a variety of formatsusing various options.Syntax: ls [options] [names]ls is a command you’ll end up using all the time. It simply stands for list. Ifyou are in a directory and you want to know what files and directories areinside that directory, type ls. Sometimes the list of files is very long and itflies past your screen so quickly .You miss the file you want. To overcomethis problem give the command as shown below:ls | moreThe character | (called pipe) is typed by using shift and the key. | more willshow as many files as will fit on your screen, and then display a highlighted“more” at the bottom. If you want to see the next screen, hit enter (formoving one line at a time) or the spacebar (to move a screen at a time). |more can be used anytime you wish to view the output of a command in thisway. A useful option to use with ls command is -l. This will list the filesand directories in a long format. This means it will display the permissions(see chmod), owners, group, size, date and time the file was last modified,and the filename.drwxrwxr-x vvs staff 2 Apr 5 09:34 sridhar.txt-rwx-rw-r” vvs staff 4233 Apr 1 10:20 resume.txt-rwx-r”r” vvs staff 4122 Apr 1 12:01 favourites.htmlThere are several other options that can be used to modify the ls command,and many of these options can be combined. -a will list all files in adirectory, including those files normally hidden. -F will flag filenames byputting / on directories, @ on symbolic links, and * on executable files.Description for the most commonly used Linux basics commandsm) manThe man command can be used to view information in the online Unixmanual.Syntax: man [options] [[section] subjects]man searches for information about a file, command, or directory and thendisplays it on your screen. Each command is a subject in the manual. If nosubject is specified, you must give either a keyword or a file. You can alsosearch for commands that serve a similar purpose. For example, if you wantmore information about the chmod command, you should type:man chmodA screen will then appear with information about chmod. Type q to quit.n) mkdirmkdir creates a new directory.Syntax: mkdir [options] directory nameFor example, to create a directory called parkhyath in the present workingdirectory, give the command as, mkdir prakhyatho) moremore displays the contents of files on your screen.Syntax: more [options] [files]To have the next line displayed, hit the return key, otherwise press thespacebar to bring up the next screen. Press h for assistance with othercommands, n to move to the next file, or q to quit.Description for the most commonly used Linux basics commandsp) lessless is similar to more in that it displays the contents of files on your screen.Unlike more, less allows backward and forward movement within the file. Itdoes not read the whole file before displaying its contents, so with large filesless displays faster than more. Press h for assistance with other commands orq to quit.Syntax: less [options] [files]q) mvmv moves files and directories. It can also be used to rename files ordirectories.Syntax: mv [options] source targetIf you wanted to rename vvs.txt to vsv.txt, you should give the command as:mv vvs.txt vsv.txtAfter executing this command, vvs.txt would no longer exist, but a file withnamevsv.txt would now exist with the same contents.Description for the most commonly used Linux basics commandsr) passwdThe passwd command creates or changes a user’s password. Only the ownerof the password or a privileged user can make these changes.Syntax: passwd [options] filess) pwdpwd prints the pathname of the current directory. If you wanted to know thepath of the current directory you were in you give the command as pwd. Youwill get the complete path.t) rmrm removes or deletes a link to a file from a directory. If a file has more thanone link then removing a link does not delete the file. But when the last linkto a file is removed, the file gets deleted.A link is a name of a file. In unix a file can have many names.Syntax: rm [options] filesIn order to remove a file, you must have write permission to the directorywhere the file is located. While removing a which does’t have writepermission on, a prompt will come up asking you whether or not you wish tooverride the write protection.The -r option is very handy and very dangerous. -r can be used to remove adirectory and all its contents. If you use the -i option, you can possibly catchsome disastrous mistakes because it’ll ask you to confirm whether you reallywant to remove a file before going ahead and doing it.Description for the most commonly used Linux basics commandsu) rmdirrmdir allows you to remove or delete directories but not their contents. Adirectory must be empty in order to remove it using this command.Syntax: rmdir [options] directoriesIf you wish to remove a directory and all its contents, you should use rm -r.Description for the most commonly used Linux basics commands
Aly Chiman is a Blogger & Reporter at AlyChiTech.com which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.