Meniu

Linux commands. The most used

Linux is a very simple Operating system to use and the commands that you use on them span across the vast majority of Linux distros. I have included a list of the most commonly used commands below.

cd

cd stands for change directory. If you put in a forward slash then it will start from the root directory eg. cd /etc if you do not put in the forward slash then it will go upwards from whatever directory you are in. eg. cd etc

ls

This is a command to list out the contents of a directory. A straight ls will only give file and directory names in the given directory. If you put in the -al options (ls -al) then you will see the following information about the files. Owner and group, permissions, size of file, date and time of the last write, and file or directory name. Some other useful options are tl (ls -tl) list the files by last write. hl (ls -hl) put file sizes in human readable format.

vi

This is the standard linux file editor. To edit a file type vi filename. To see a list of commands within vi click here

cat, more, less

These are all different ways of viewing files. cat will just output the whole file. While more and less will let you scroll through the file and let you press the forward slash key to search within the file.

grep

This is used for searching for strings matching a regular expression. To use it you can type something like; grep something filename.txt You can also use a * for a wildcard eg. grep something *.txt

top

Top shows the processor and memory usage in real time. It is the Linux equivalent to the task manager in windows. As well as listing all processes sorted by cpu and memory usage it also shows disk wait and load average of the server. The load average is the amount of processes waiting to be written. It is shown in three numbers like below; load average: 2.42, 2.30, 2.16 They are the averages from left to right over a period of 1, 5 and 15 minutes.

rm

rm stands for remove. You can remove a file by simply typing rm filename.txt. Or you can remove a whole directory you need to use the -rf option - rm -rf directory. You can also use the * as a wildcard. So for instance if you want to delete all the files ending in .pdf you could run the command rm *.pdf. That will delete all files with the string .pdf in that particular directory. You can use the -f option if you do not want to be prompted for every single file deletion - rm -f *.pdf. Be very careful when running this command as there is no warning and it could quite easily delete files you want to keep if you run it incorrectly. For instance rm -f * deletes all files from a directory and rm -rf * deletes all files and directories from a directory.

find

There are other better ways of finding files on a linux system such as locate however find is a native Linux command and so is available on all Linux systems. You can find a file by running the following command;
find ./* -iname filename -print
Again you can use the * option in the filename or directory name. If you want the search to be case sensitive then simply use -name instead of -iname.

More

This is a list of the most basic Linux commands. There will be an advanced page along soon covering topics such as awk, screen, tee and a whole lot more!

Mirela

Zona de mobile
  • | 34 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign