Results 1 to 6 of 6
01-10-2015, 09:08 AM #1
- Join Date
- May 2005
03-03-2015, 10:59 AM #2
- Join Date
- Mar 2015
My top 15 linux commands ** that everyone should master!
# 1: cd
The "Change Directory" command enables you to navigate to another directory.
The cd command is THE most important command there is in linux i think. As the command suggests, it enables the user to change / jump to a directory.
Example: cd Downloads
Example: cd /etc/
Example: cd .. (Directory up!)
note: Afther you have typed cd and entering the first or two letters of the directory you can press the TAB key to autocomplete the directory! so... cd Do (press tabkey) will autocomplete it to Downloads. i use this a lot <--
The man command shows the users the "manual" of the command. In some situation you might need to get more information about the command you are using. The man command shows you this information about the command.
Example: man cp
This will open up the "cp" manual document for us in the shell. The manual shows us the parameters available for the commands.
note: To close the manual simply press "Q".
In the absolute top 15 there's no way the ls command is missing. On the third place, the ls command. The ls command is used to list the files/directories within a directory.
It shows us the directories available.
The cp command is available for us to "Copy" things. This might be usefull for duplicating files f.e.
Example: cp file file2
note: file is on this case the file the user wants to be copied... file2 is the name of the copied file. It's that simple.
The mv command is used for "Move" operations. The mv commands enables the users to move a file/directory to a specified location.
Example: mv /home/bas/Desktop/bla /home/bas/Desktop/fiets
note: the first part of the command is the file that has to be moved. The second part (after the whitespace) is the target directory. Make sure you type in the full path using this command!
This command is used to "make" directories, NOT Files.. (thit is possible with another command which i will bring up later in this tutorial)
Example: mkdir testdirectory
note: The name of the directory is case sensitive which means that Testdirectory is a complete different directory as testdirectory.
When you are able to make directories, you also want to know how to remove them. Removing directories is done by the rmdir command and belongs to the absolute basic commands in shell bashing.
Example: rmdir fiets
note: When the directory is not empty the command will prompt an error message:
rmdir: failed to remove `fiets': Directory not empty
So make sure it's completely empty before removing it.
Now we know how to make directories and deleting them, i now want to use the touch command. The touch command is used to make files.
Example: touch vogel
This will create the file vogel for us in the directory.
The rm command stand for remove. The rm command is used in order the delete files instead of directories.
Example: rm vogel
note: To remove files you must have the right permission bits set on the specific file.
Sometimes you have to archive files. Archiving files is a way to pack a set of files to one single file. The operation is done by the tar command.
Example: tar -cvf test.tar test (Creating a tar file from directory or file test)
Example: tar -xvf test.tar myexctractfolder (Extracts the particular tar file in the current working directory)
In the example i used parameters. These parameters are telling the tar command how to behave and how to execute. After the parameters i entered the name of the file which is test.tar. The second part is the source directory/file of the tar file. In this situation a directory called test.
Sometimes you really wonder where you are in the system. PWD is the solution for that problem.
PWD stands for Path Working Directory.
ifconfig is a command showing you information about the ethernet adapters on your system. It contains very usefull information like gateway, ip, and packet statistics. For the average user this command is rarely used, but i think it's worth knowing it.
note: To gain information about the wireless adapters on your system type iwconfig.
Locate is an extremely fast seaching command. It shows the directories or files each on a new line.
Example: locate syslog
Example: locate syslog | more (Piping structure used to invert the data from locate to the more command)
note: Some keywords returns enormous ammounts of hits. Use MORE to (see example) clear things up a bit.
Ping is used as a network diagnostic command by professionals. Ping offers information about the network we are on and if the other system responds to us. In cases of troubleshooting network related problems, ping can do a great job to determine the domain of the problem.
Example: ping www.google.com
The command returns the interval and % of loss during the test.
note: You can stop ping bij pressing crtl-c at the same time.
The chmod command. The chmod command comes from "Change Mode" back to the unix times. It's a great command to restrict access to directories or files. But before i show you an example on how to use it, some theory.
Chmod is qiet an advanced command to use. So therefore you really need to understand how it works.
chmod works with so called persmission bits. These bits can be set to a certain level of restrictions.
We have the following bits available:
7 full 6 read and write 5 read and execute 4 read only 3 write and execute 2 write only 1 execute only 0 none
The bits shown above are the permissions for a particular group or class.
Files or directories contain four classes:
1st: The owner itself
2nd: Member of the file group
4th: All of the above
To set the right permission bits the a particular group or class it is very important to select to right amount of permission bits.
for example, i will create a file and protect this file for being modified by anyone else besides me. Also will i protect the file for being deleted.
This is how i do it: chmod 400 mijndagboek
In this command i gave up the 4 bit in the "members of the group" 0 to others and 0 to all.
Now not even me is able to delete the file anymore without using the sudo command.
But.. there is more. The classes i talked about earlier are devided into three seperate like actions.. those are:
In order to add very specific restrictions to a file or folder you can use a trick to do that. I will show you how.
If we want to restrict access to a file without knowing the exact bit number we can do the following.
RWX = 7 Which is the permission bit of Read, Write, and Execture together.
Seperating these bits gives us the following values individually:
Read = 4 bits.
Write = 2 bits.
Exec = 1 bit.
So we have 3 groups to take care of (the first group which is the owner is optional in chmod)
if we want to give everyone, and i mean everyone access to the directory i can do:
chmod 777 mijndagboek
This is not good!
We want to restrict the access for the file offcourse so a better chmod would be:
03-10-2015, 02:01 AM #3
- Join Date
- Mar 2015
Thanks for the list ... these are some of the most used commands ....
08-27-2016, 03:32 AM #4
- Join Date
- Aug 2016
cat [filename] Display file’s contents to the standard output device
(usually your monitor).
cd /directorypath Change to directory.
chmod [options] mode filename Change a file’s permissions.
chown [options] filename Change who owns a file.
clear Clear a command line screen/window for a fresh start.
cp [options] source destination Copy files and directories.
date [options] Display or set the system date and time.
df [options] Display used and available disk space.
du [options] Show how much space each file takes up.
file [options] filename Determine what type of data is within a file.
find [pathname] [expression] Search for files matching a provided pattern.
grep [options] pattern [filesname] Search files or output for a particular pattern.
kill [options] pid Stop a process. If the process refuses to stop, use kill -9 pid.
less [options] [filename] View the contents of a file one page at a time.
ln [options] source [destination] Create a shortcut.
locate filename Search a copy of your filesystem for the specified
lpr [options] Send a print job.
ls [options] List directory contents.
man [command] Display the help information for the specified command.
mkdir [options] directory Create a new directory.
mv [options] source destination Rename or move file(s) or directories.
here is list of some common commands.
09-27-2016, 06:28 AM #5
- Join Date
- Sep 2016
My top linux comnands:
2. tar tvf
19 ps -x
10-18-2016, 08:42 AM #6
- Join Date
- Oct 2016
I like to use below commands