Sie sind auf Seite 1von 18

Linux

By Klaus Gugenberger

45

Linus Torvalds

nano – Texteditor

nano /etc/network/interfaces - Network interfaces

service networking restart – рестартира нетуъркинг сървиса кат смениш ИП адрес и т.н.

ip address – показва ип

du | df

cat - used to type out a file (or combine files)

head - used to show the first few lines of a file

tail - used to show the last few lines of a file

man - used to view documentation.

man -k - A list of the man pages discussing the subject = whatis

man –a - All man pages in sequence with the given name in all chapters = apropos
Съдържание
Linus Torvalds .......................................................................................................................................... 1
List Installed Commands Here: (LICS) ...................................................................................................... 2
Start/Stop GUI ..................................................................................................................................... 3
vi – Текст едитор като Nano ................................................................................................................ 3
logical operators: ................................................................................................................................. 6
What is Sticky Bit? ................................................................................................................................... 7
How can I setup Sticky Bit for a Folder? .......................................................................................... 8
How can I setup SUID for a file? .......................................................................................................... 8
After setting SUID bit:...................................................................................................................... 9
What is Umask and How To Setup Default umask Under Linux?.......................................................... 10
Navigating the Directory History ....................................................................................................... 10
You can change the Bash Shell Colors links: ...................................................................................... 10
Shut Down PC Commands : ............................................................................................................... 10
Shells List: .............................................................................................................................................. 12
SSH Secureshell Verbindung.................................................................................................................. 12
Character Classes............................................................................................................................... 13
Recursive Copy: ................................................................................................................................. 14
Definition of Force: ............................................................................................................................ 14
Hard links ........................................................................................................................................... 14

List Installed Commands Here: (LICS)


1. tree -d – shows tree structure (-d just directories)
2. mc – like Norton Commander Ctr+o to switch between mc and shell
http://midnight-commander.org/
3. proftpd – некъв ftp клиент…
/etc/proftpd/ - config files folder
4. vsftpd (Very Secure FTP Daemon) – Recommended by ELI
5. locate – Search for a file in a database
http://proftpd.org/
https://github.com/proftpd/proftpd/
ftp://10.20.30.148/
6. WinSCP – FTP Client for Windows
7. FileZilla – FTP Client for Win – Recommended by ELI
8. dump – Filesystem Bakcup
9. openssh-server – Remoteshell Server
10. PuTTy – ssh Win Client
11. info – like man, but uses data from GNU Info System
12. mysql-server -> first install this then install phpmyadmin or it do not work…
13. phpmyadmin must reconfigure using root instead of phpmyadmin as user
dpkg-reconfigure phpmyadmin
14.

Start/Stop GUI
 sudo systemctl stop gdm (or sudo telinit 3)
 and restart it (after logging into the console) with:

 sudo systemctl start gdm (or sudo telinit 5)

 On Ubuntu, substitute lightdm for gdm.

pwd – print working directory

vi – Текст едитор като Nano


i – Activates Insert Mode

:w – Write to disk

:q -quit

more <file name> - shows file contents (text files)

shutdown – shuts pc down

restart – WOW restarts pc

cp , mv – copy and move

cp * -r – rekursiv копира и подпапките (иначе копира само файловете)

rm - remove (delete) | rmdir – remove directory

rm –i Interactively remove a file (asks are you sure)


While typing rm –rf is a fast and easy way to remove a whole filesystem tree recursively, it is
extremely dangerous and should be used with the utmost care, especially when used by root (recall
that recursive means drilling down through all sub-directories, all the way down a tree). Below are
the commands used to rename or remove a directory:

rm -f <filename> - removes files or folders FORCEFULLY, Force means ignores nonexistent files and
arguments, never prompts for conformation

rm -rf Forcefully remove a directory recursively (Deletes all files and subfolders)

mkdir <dir name> – make dir.

dd if=/dev/sda of=/dev/sdb – copy, format drives and partitions !!! if- Input file; of-Output
file.

dd if=/dev/urandom of =/dev/sda bs=4k - Wipes Hard Drive urandom is The Random


Generator…

lsblk – Shows all the Block Devices bs=4k means random numbers in 4k

blocks

~ - Means ‘My Home Directory’

nano /etc/apt/sources.list -некъв списък от къде да тегли ъпдейти…

apt-get update and apt-get upgrade (advanced packaging system)

updates sources file - /etc/apt/sources.list

apt-get remove --purge – removes app with the settings files

apt-get remove autoremove – uninstalls libraries that were installed with other apps

ifconfig – (Network) Interface Configuration

ifconfig eth0 up/down – turn on/off specified internet connection…

iwconfig – WiFi configuration show


PERMISSIONS:

Installieren Links – некъв текстов браузър …

http://links.twibright.com/user_en.html

touch – създава файлове и може да променя некви Zeit атрибути

To set the time stamp to a specific time:


$ touch -t 03201600 myfile

This sets the myfile file's time stamp to 4 p.m., March 20th (03 20 1600).

echo – пише на екрана.

echo $HOME – пише пътя на хоум фолдера

chmod 777 <filename> /r 4 w2 x1/


chmod u=rwx,g=rx,o=r myfile
chown [<Owner>]:[<Group>] file name/folder(change owner)

chown root data – changes the owner of data to root

chown :users data – changes the group to data.


chown user4:usergroup /path
group (changes group of a file)

passwd – changes Acc Password

grep – (Global Regular Expression Print) търси текст във файл

grep -i „text“ – searches for text, TEXT; Text (case insensitive)


-v – “inverted match” prints all the lines which do not contain the search text

grep -n – shows on Line Number

df -h (human readable) – Disk space free

du -s (smmary) -h – Disk Space used by files

free -m /-g – shows free space in MB or GB

watch (other command) – repeats other command every 2 sec -n 1 to change interval to 1

wc - (word count) shows number of LINES WORDS CHARACTERS in a text file

cal – shows calendar

date [-s] - shows the system date (-s sets a new date)

logical operators:
ls && cal - if ls fails cal won’t execute

ls || cal - if ls executes cal won’t

tar – Tape Archive file

tar -cvf (compress visual guide filename) filename.tar path

-x – extract

-z creates/extracts a filename.tar.gz file

uname -a - Инфо за Линукса

who – info for the User

cat /etc/shadow – тука стои всичко, потребители пароли, етц. Моеш с лайв диск да се
ебаваш с паролите (хаш парола от друга система копи там и ше моеш да се логнеш на тая
система)

useradd – low level utility for adding users. Usually Admins use adduser instead. User is deactivated,
password must be set using passwd. Good for installing new services (DNS server controller account.
Has rights to control only the DSN server) od. MailAdmin.
useradd -m -s /bin/bash -g users
-m – Make Home Directory (Прай папка у Home)

-p crypt(password) – adds user password

-s /bin/bash – set which shell the user will use


-g users – assigns user to specified Usergroup (users)

-c “Write comment here” – Writes a comment

adduser – “standard for adding users”

usermod – Changes a user Account

pwd – shows current path.

ps -x – показва подробни данни за процесите

Има някакво писано правило у Линукса да се пишат папките с Главна буква а данните с малка.

less und more – некви програми за отваряне на файлове като четец за текст…

Using less here - https://www.lifewire.com/what-to-know-less-command-4051972

./myscript.sh – Executes Script

whatis – Shows short description of an app

which – shows the path to an app

groups – показва с кои групи е свързан текущия потребител

cat /etc/groups – показва всички съществуващи групи

gpasswd – оправляваш etc/groups и etc/gshadow

.bashrc – file settings for the bash shell

Touch datei{1..100} - прави файлове с име datei1 – datei100

cd - change to previous directory (cd remembers the last active directory)

Bits n Tits

What is Sticky Bit?

Sticky Bit is mainly used on folders in order to avoid deletion of a folder and it’s content by other
users though they having write permissions on the folder contents. If Sticky bit is enabled on a folder,
the folder contents are deleted by only owner who created them and the root user. No one else can
delete other users data in this folder(Where sticky bit is set). This is a security measure to avoid
deletion of critical folders and their content(sub-folders and files), though other users have full
permissions.
sticky Bit – only the owner and root can delete, in ls -l shows as T

How can I setup Sticky Bit for a Folder?


Sticky Bit can be set in two ways
1. Symbolic way (t,represents sticky bit)
2. Numerical/octal way (1, Sticky Bit bit as value 1)

Use chmod command to set Sticky Bit on Folder: /opt/dump/

Symbolic way:

chmod o+t /opt/dump/


or
chmod +t /opt/dump/
Let me explain above command, We are setting Sticky Bit(+t) to folder /opt/dump by using chmod
command.

Numerical way:
chmod 1757 /opt/dump/

Here in 1757, 1 indicates Sticky Bit set, 7 for full permissions for owner, 5 for read and execute
permissions for group, and full permissions for others.

Checking if a folder is set with Sticky Bit or not?

Use ls -l to check if the x in others permissions field is replaced by t or T

Sticky bit without Executable permissions:

so if you want executable permissions, Apply executable permissions to the file.


chmod o+x /opt/dump/

How can I setup SUID for a file?


SUID can be set in two ways

1) Symbolic way (s, Stands for Set)

2) Numerical/octal way (4)

Use chmod command to set SUID on file: file1.txt


Symbolic way:
chmod u+s file1.txt
Here owner permission execute bit is set to SUID with +s

Numerical way:
chmod 4750 file1.txt
Here in 4750, four indicates SUID bit set, seven for full permissions for owner, five for read and
execute permissions for group, and no permissions for others.

How can I check if a file is set with SUID bit or not?

Use ls –l to check if the x in owner permissions field is replaced by s or S

For example: Listing file1.txt before and after SUID set

Before setting SUID bit:


ls -l
total 8
-rwxr--r-- 1 xyz xyzgroup 148 Dec 22 03:46 file1.txt
After setting SUID bit:
ls -l
total 8
-rwsr--r-- 1 xyz xyzgroup 148 Dec 22 03:46 file1.txt

What is SUID numerical value?


It has the value 4.

Multiple slashes (/) between directories and files are allowed, but all but one slash between
elements in the pathname is ignored by the system. ////usr//bin is valid, but seen as
/usr/bin by the system.

Most of the time, it is most convenient to use relative paths, which require less typing. Usually, you
take advantage of the shortcuts provided by: . (present directory), .. (parent directory) and ~
(your home directory).

ls -a – lists all files including hiddenfiles .filename


$ ls -li
The -i option to ls prints out in the first column the inode number, which is a unique quantity for
each file object. This field is the same for both of these files; what is really going on here is that it is
only one file but it has more than one name associated with it, as is indicated by the 2 that appears
in the ls output. Thus, there was already another object linked to file1 before the command was
executed.

If you edit one of the files, exactly what happens depends on your editor; most editors,
including vi and gedit, will retain the link by default, but it is possible that modifying one of the
names may break the link and result in the creation of two objects.

ln - is used to create hard links and (with the -s option) soft links
What is Umask and How To Setup Default umask Under Linux?
https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

umask – shows umask for folder

umask 0000 – sets umask

You can setup umask in /etc/bashrc or /etc/profile file for all users. By default most Linux distro set
it to 0022 (022) or 0002 (002).

Navigating the Directory History


The cd command remembers where you were last, and lets you get back there with cd -. For
remembering more than just the last directory visited, use pushd to change the directory instead of
cd; this pushes your starting directory onto a list. Using popd will then send you back to those
directories, walking in reverse order (the most recent directory will be the first one retrieved with
popd). The list of directories is displayed with the dirs command.

pushd . - saves current working directory into a list /does not work without a path (.)

popd – moves you to the last saved directory in the list

dirs – shows list of saved directories

You can change the Bash Shell Colors links:


In the /~.bashrc file

http://ezprompt.net/ - Colors Generator

https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

Shut Down PC Commands :


Shutdown -h now
halt
poweroff

whrereis and which


Note whereis also reports the location of the man page.

cat Used for viewing files that are not very long; it does not provide any scroll-back.
tac Used to look at a file backwards, starting with the last line.
Used to view larger files because it is a paging program; it pauses at each screen full of text,
provides scroll-back capabilities, and lets you search and navigate within the file. Note: Use
less
/ to search for a pattern in the forward direction and ? for a pattern in the backward
direction. (An older program named more is still used, but has fewer capabilities.)
Used to print the last 10 lines of a file by default. You can change the number of lines by
tail doing -n 15 or just -15 if you wanted to look at the last 15 lines instead of
the default.
head The opposite of tail; by default, it prints the first 10 lines of a file.

apt-cache search ftpd* – Searches for an app in the app cache (if you know some of the name)

apt-cache policy <appname> - Shows app version and newest available version…

http://www.securityfocus.com/ - некъв сайт с Vulnerabilities !


Shells List:
/etc/shells – List with all available shells 😊

Wildcard Result

? Matches any single character

* Matches any string of characters

[set] Matches any character in the set of characters, for example


[adf] will match any occurrence of "a", "d", or "f"

[!set] Matches any character not in the set of characters

SSH Secureshell Verbindung


For remote controlling online-enabled Linux Server

 http – Port 80
 shttp – Port 442 + Certificate
 e-mails – Port 25
 SCP – Port 22 Secure Copy Protocol

SSH – Secure Shell Connection

scp /home/www/data.txt root@10.20.30.179:/var/www - securecopy to remote machine

http://10.20.30.54/phpmyadmin
To get wordpress –

 cd /var/www/html - must download the file in here !


 wget https://wordpress.org/latest.tar.gz

Man Pages or Help me, please


The “manual” that man displays is broken into sections and not only covers user com-

mands but also system administration commands, programming interfaces, file formats

and more. The table below describes the layout of the manual:

Character Classes
[[:class:]] Matches any character that is a member of the specified class

[:alnum:] Matches any alphanumeric character

[:alpha:] Matches any alphabetic character

[:digit:] Matches any numeral

[:lower:] Matches any lowercase letter


[:upper:] Matches any uppercase letter

EXAMPLE:

[[:upper:]]* Any file beginning with an uppercase letter

[![:digit:]]* Any file not beginning with a numeral

*[[:lower:]123] Any file ending with a lowercase letter or the numerals “1”, “2”, or “3”

Recursive Copy:
cp dir1/* dir2 - Using a wildcard, all the files in dir1 are copied into dir2. dir2 must already
exist.

cp -r dir1 dir2 - Copy the contents of directory dir1 to directory dir2. If directory dir2 does
not exist, it is created and, after the copy, will contain the same contents as directory dir1.

If directory dir2 does exist, then directory dir1 (and its contents) will be copied into dir2.

Definition of Force:
-f, --force - Ignores nonexistent files and do not prompt. This overrides the –interactive
option.

rm -r file1 dir1 - Delete file1 and dir1 and its contents.

rm -rf file1 dir1 - Same as above, except that if either file1 or dir1 do not exist, rm will
continue silently.

Be particularly careful with wildcards. Consider this classic example. Let's say you want to delete just
the HTML files in a directory. To do this, you type:
rm *.html
which is correct, but if you accidentally place a space between the “*” and the “.html” like so:
rm * .html
the rm command will delete all the files in the directory and then complain that there is no file called
“.html”.

test rm with lm first…´

Hard links
cannot span physical devices and hard links cannot reference directories, only files.

Setting up aliases
alias name='string' Example: alias lsl=’ls -cl’
> filename.txt – Creates an empty file
Using \ to print special characters:

Cursor Movement Shortcuts


Seek LPI Test

The fact that a program can launch other programs is expressed in the process scheme as

a parent process producing a child process.

131/155

Apt-get purge – deletes the configurations files also /etc/

Apt-get remove – leaves the config files !!!

SUSE gibt e skein /var/ Verzeichniss

uname - r – Shows the Linux Core version:

Weiss ich die Verzeichniss Struktur AUSWENDIG

https://en.wikipedia.org/wiki/ANSI_escape_code - ANSI ESCAPE CODES


Searching for Installation Packages

Installing Package

Installing from Package

Checking Package Status:

See information about a Package


See which Program installed a File

233

Das könnte Ihnen auch gefallen