Update 'README.md'
This commit is contained in:
parent
3a34bfd2de
commit
378d1bb937
1 changed files with 197 additions and 2 deletions
199
README.md
199
README.md
|
@ -1,3 +1,198 @@
|
|||
# Important-Linux-commands
|
||||
## Important-Linux-commands
|
||||
|
||||
The commands which make life in cyberspace easier.
|
||||
|
||||
In the shell, you have to imagine the jumps. Because the computer will only be
|
||||
projecting code in your mind from your mind.
|
||||
|
||||
You are a specific point on some system, when you are in the shell.
|
||||
you can see what is in the directory you are with the command
|
||||
|
||||
# ls
|
||||
|
||||
this command also can display other useful information. Of what is inside the directory
|
||||
you are in.
|
||||
|
||||
# cd
|
||||
|
||||
The most important one.
|
||||
Instead to click, you change directories via command.
|
||||
that makes it possible to jump from one point to the other, especially with autocompletion.
|
||||
|
||||
|
||||
# man
|
||||
|
||||
In general you can get the manual entries for each of the programs described here and much more.
|
||||
|
||||
Just type
|
||||
|
||||
man cd
|
||||
|
||||
or type
|
||||
man ls
|
||||
|
||||
and you will get the manual opened historically with nano or less.. not sure, both good old editors.
|
||||
|
||||
# cp
|
||||
|
||||
copy files from one place to another. (relatively from you)
|
||||
|
||||
cp /dirA/file1.py /dirB/file1.py
|
||||
|
||||
when there is already file1.py in the destination directory, it gets overwritten.
|
||||
|
||||
|
||||
|
||||
# Concept of piping with >
|
||||
|
||||
in the shell you have standard input and standard output.
|
||||
Nothing more.
|
||||
to pipe the standard output from one program into a file, you write it like this:
|
||||
|
||||
ls > file.txt
|
||||
|
||||
When you write like that, youll overwrite everything in the file with the output.
|
||||
|
||||
If you want to append to a file what a program has as standard output,
|
||||
you can use >> instead. Writing it like this:
|
||||
|
||||
ls >> file.txt
|
||||
|
||||
This both is piping. There is another very important aspect of piping described later.
|
||||
|
||||
# alias
|
||||
|
||||
|
||||
give your complicated commands easy remember commands.
|
||||
Or build the own language of your shell.
|
||||
|
||||
alias cls=clear
|
||||
|
||||
This sets up an alias called cls. It will be another name for clear. When you type cls, it will clear the screen just as though you had typed clear.
|
||||
|
||||
On my Arch Linux, I can write these aliases in my bashrc config file. I need to issue the command
|
||||
|
||||
source bash_profile
|
||||
|
||||
to get the configuration loaded. On other linux there will be an analogon.
|
||||
|
||||
|
||||
|
||||
# cat
|
||||
|
||||
print out what you have in front of you on the standard output.
|
||||
|
||||
also print several together
|
||||
|
||||
for instance:
|
||||
|
||||
cat doc1.txt doc2.txt > doc1ANDdoc2.txt
|
||||
|
||||
|
||||
# chown
|
||||
|
||||
On linux everything are only directories and (txt)files.
|
||||
All these objects have an owner, or also multiple ones.
|
||||
|
||||
sudo chown -R root /ole/ola/kp.txt
|
||||
|
||||
gives root the ownership of kp.txt
|
||||
|
||||
# chmod
|
||||
|
||||
Every owner then has file permissions. That means he can read write or x (do) something.
|
||||
he can do all of them or some of them or none of them. Thats defined in codes, 777 gives them all and 660 doesnt completely.
|
||||
|
||||
sudo chmod 777 ole/oi/file.txt
|
||||
|
||||
bzw
|
||||
|
||||
sudo chmod 660 ole/oi/file.txt
|
||||
|
||||
|
||||
Just look it up what people say regarding permissions and certain directories.
|
||||
|
||||
# history
|
||||
|
||||
this lists all the commands of the shell you are in, that you have typed in lastly.
|
||||
|
||||
# grep
|
||||
|
||||
|
||||
if you have some bigger output of some of the former commands for example. Or whatever big output. then use grep to filter out the lines that have a certain word in it.
|
||||
GRAB it.
|
||||
|
||||
# piping with |
|
||||
|
||||
here comes into account the piping with |.
|
||||
|
||||
Directly combining it with the history command is pretty effective..
|
||||
|
||||
history | grep "whatsoevercommandIalreadyfiguredoutbutreallydontwanttosearchoutagain"
|
||||
|
||||
here the output of history gets piped into the program grep.
|
||||
as the output of history gives one command per line, grep will filter out exactly the command in which the pattern "whatsoever" occur.
|
||||
|
||||
|
||||
# getting some INFO about the system
|
||||
|
||||
|
||||
# df
|
||||
|
||||
prints you out disc usage of your hardware
|
||||
|
||||
df -h
|
||||
|
||||
does it in humanreadable
|
||||
|
||||
|
||||
# du
|
||||
|
||||
prints out the size of files around you
|
||||
|
||||
du -h -d 2
|
||||
|
||||
prints in human readable with depth 2, that means in the directories and in their subdirectories.
|
||||
|
||||
|
||||
# lsblk
|
||||
|
||||
prints you out all the hardware devices with memory
|
||||
|
||||
|
||||
# htop respectively top
|
||||
|
||||
gives you a terminal graphics programm interface to see all running processes
|
||||
|
||||
|
||||
# tail -f
|
||||
|
||||
with tail or also head, you can print out the last or the first lines of a file
|
||||
|
||||
When you use tail -f, you get a stream of the documents last lines.
|
||||
|
||||
Thats perfect for some log files that get written.
|
||||
|
||||
# journalctl -f
|
||||
|
||||
this gives you a stream of the kernel messages, which are pretty a lot about a lot of different topics of the programs on your machine.
|
||||
|
||||
The kernel is the ground software, running the hardware of the proper materia device.
|
||||
Its mostly in C.
|
||||
C is like the base of all languages. (if its not assembly)
|
||||
|
||||
# uname (-a or -r or other)
|
||||
|
||||
gives you general infos about system, OS, and stuff
|
||||
|
||||
# systemctl
|
||||
|
||||
some people do not like systemctl.
|
||||
I personally have parts of my structures that are managed by this software.
|
||||
with
|
||||
|
||||
sudo systemctl status nginx.service
|
||||
|
||||
I ask systemctl to give me the status of the nginx daemon, running in the background of my (and actually all of my machines there is running one nginx daemon) machine.
|
||||
|
||||
|
||||
The commands which make life in cyberspace easier
|
Loading…
Reference in a new issue