Professional Documents
Culture Documents
Prep
Manipulating Text I/O
Input/Output Redirection:
Every command has: command STDIN STDOUT STDERR
- Not all commands listen for STDIN
- By default:
- STDIN -> comes from keyboard
- STDOUT -> goes to console
- STDERR -> goes to console
I/O Redirection Symbols:
< : Redirect STDIN (0=assumed)
> : Redirect STDOUT (1=assumed)
2> : Redirect STDERR
| : pipe results into STDIN of a command
>> : this will append instead of overwriting
& : used if redirecting STDERR into STDOUT, or vice versa
Using Runlevel with init and telinit and shutdown (telinit is the
proper way):
The init, telinit directly goes to the runlevel, while the shutdown
command send a warning to users on CLI.
commands:
telinit <number> <- switch to runlevel
shutdown <time> <- switch to runlevel 1
shutdown -r <time>
<- switch to runlevel 6
shutdown -h <time>
<- switch to runlevel 0
(time=now, it shut down immediately)
runlevel
<- shows the currently in and the previous
runlevel)
change the default runlevel:
vim /etc/inittab
Change runlevel on bootup:
1. Go to GRUB Menu: press any key couple of times
2. Modify the kernel arguments before booting (edit the argument):
press "a"
3. type: 1 (goes to the single user mode)
Physical Volumes:
pv
Volume Group:
vg
Logical Volume:
lv
Resize filesystem:
resize2fs
Checking filesystem: df -h
mkfs. -> creating a filesystem (mkfs.ext4, mkfs.ext2)
mkdir /mnt/<a new folder name>
mount -t ext4 /dev/sdb3 /mnt/<a new folder name> -> mounting
the filesystem to a folder
umount /mnt/<a new folder name>
Encrypted partitions: LUKS (Linux Unified Key Setup):
First we need to create the encrypted partition and after we need to
add the filesystem.
cryptsetup luksFormat /dev/sbd3
cryptsetup luksOpen /dev/sdb3 <give a name for the device> <Mount this partition to an unencrypted way
cryptsetup luksClose <name of the device>