apt update | update the local package index with the latest changes made in the repositories |
apt upgrade | upgrade installed packages |
apt install package | install package |
apt remove package | remove installed package |
systemctl start service | start service |
systemctl status service | check the status of service |
systemctl stop service | stop service |
systemctl enable service | enable the service to start at system startup |

Linux Cheat Sheet
Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds.
Linux General
Package management
cron jobs
at time | schedule command to run at time |
atq | view pending jobs |
atrm 2 | remove job 2 from the scheduled commands |
crontab -e | set cron jobs |
0 2 * * * /dir1/script.sh | run script /dir1/script.sh at 2pm daily |
crontab -l | show the list the cron jobs of current user |
Compress and archive
tar -cf /dir1/backup.tar /dir2 | create tar archive file /dir1/backup.tar for /dir2 |
tar -xvf /dir1/backup.tar -C /dir2/ | extract tar archive file /dir1/backup.tar to /dir2/ |
Text search and manipulation
grep text file1 | display the lines that contains text in file1 |
grep -ni text file1 | ignore the case and display line numbers of the matched lines |
awk -F',' '{print $1"@"$3}' | print col1@col3 |
awk -F'\t' '/str/ {print $0}' | print line with str |
User and Group Management
useradd user1 | create user1 user account |
passwd user1 | create password for user1 user |
su | switch user account |
exit | logout user |
userdel user1 | delete user account user1 |
usermod -l user2 user1 | change user1 login name to user2 |
groupadd group1 | add group group1 |
groupdel group1 | delete group group1 |
gpasswd -a user1 group1 | add single user user1 to group group1 |
gpasswd -M user1,user2 group1 | add multiple users user1 user2 to group group1 |
gpasswd -d user1 group1 | remove user user1 from group group1 |
gpasswd -A user1 group1 | make user1 as admin of group1 |
System and process monitoring
uptime | show current uptime |
df | show disk usage |
du | show directory space usage |
free | show memory and swap usage |
ps | show all current active processes |
top | task manager program displays information about CPU and memory utilization |
kill pid | kill process with process id pid |
bg | list stopped or background jobs |
lsof | Lists all files opened by any process of a system |
lsof -u user1 | Lists all files opened by user1 |
Networking
ifconfig or ip addr | show ip address |
nmcli con show | show list of connections |
nslookup | queries the DNS server for information about a domain name or IP address |
iptables | sets up, maintains, and inspects the tables of IPv4/IPv6 packet filter rules in the Linux kernel firewall |
ping host | send packets to host to check the connectivity |
ping -c 5 host | send 5 packets to host |
curl | facilitates the transfer of data to or from a server, using any of the protocols it supports |
netstat | Displays network connections and network statistics, such as active sockets, routing tables, and network interface statistics |
ss-keygen | Creates a pair of public and private authentication keys |
ssh user@host | connect user to host using ssh |
scp file1 user1@host:/dir | copy file1 from local to remote host host to /dir location |
Working with directory and files
mkdir dir | create single directory dir |
mkdir dir1 dir2 | create multiple directories dir1 dir2 |
mkdir -p dir/a/b/c | create nested directory dir/a/b/c |
mkdir dir{1..10} | created 10 numbered directories from dir1 to dir10 |
rm -r dir | remove dir recursively |
touch file | create empty file file |
touch file1 file2 | create multiple files file1 file2 |
touch file{1..10} | create 10 numbered files from file1 to file10 |
cp -rf /dir/file1 /dir2 | copy file file1 to dir2 directory recursively and forcefully |
mv /dir/file1 /dir2 | move file file1 to dir2 directory |
rm file1 | remove file file1 |
ls -al | show files - both regular & hidden files and their permissions |
cat file1 | display contents of file1 |
find /dir1 -name file1 | find file1 under /dir1 directory |
find /dir1 -perm 664 | find all files/directories with read, write permission to owner and group, read permission for others in directory dir1 |
find /dir1 -empty -exec rm -r {}** | find and remove all empty files/directories from /dir1 |
wc -l file1 | count the number of lines in file1 |
wc -w file1 | count the number of words in "file1* |
head file1 | display top 10 lines of file1 |
head -n 20 file1 | display top 20 lines of file1 |
tail file1 | display last 10 lines of file1 |
tail -n 20 file1 | display last 20 lines of file1 |
Basic info
pwd | show present working directory |
uname | show name of the kernel |
uname -r | show kernel version |
cd | change directory |
clear | clear the screen |
whoami | show current login user name |
history | show list of previously used commands |
date | show time and date |
echo "Hello" | display Hello text |
sudo | run commands as super user |
File Permission Numbers
Calculate permission digits by adding numbers below | |
4 | read (r) |
2 | write (w) |
1 | execute (x) |
Nano Shortcuts
Files | |
Ctrl-R | Read file |
Ctrl-O | Save file |
Ctrl-X | Close file |
Cut and Paste | |
ALT-A | Start marking text |
CTRL-K | Cut marked text or line |
CTRL-U | Paste text |
Navigate File | |
ALT-/ | End of file |
CTRL-A | Beginning of line |
CTRL-E | End of line |
CTRL-C | Show line number |
CTRL-_ | Go to line number |
Search File | |
CTRL-W | Find |
Directory Operations
pwd | Show current directory |
mkdir dir | Make directory dir |
cd dir | Change directory to dir |
cd .. | Go up a directory |
ls | List files |
Tar Command Examples
tar -cvf a.tar /dir | Create a tar archive called a.tar for dir |
tar cvzf a.tar.gz /dir | gzip compressed archive |
tar -xvf Archive.tar.gz | Uncompress |
v | show the progress of archive file |
c | create a archive file. |
x | extract a archive file. |
f | filename of archive file |
t | viewing content of archive file. |
j | filter archive through bzip2. |
z | filter archive through gzip |
r | append or update files |
File Permissions
chmod 775 file | Change mode of file to 775 |
chmod -R 600 folder | Recursively chmod folder to 600 |
chown user:group file | Change file owner to user and group to group |
First digit is owner permission, second is group and third is everyone. | |
4 | read (r) |
2 | write (w) |
1 | execute (x) |
Process Management
ps | Show snapshot of processes |
top | Show real time processes |
kill pid | Kill process with id pid |
pkill name | Kill process with name name |
killall name | Kill all processes with names beginning name |
Watch a Command
watch -n 5 'nt -p' | Issue the 'ntpq -p' command every 5 seconds and display output |
File Operations
touch file1 | Create file1 |
cat file1 file2 | Concatenate files and output |
less file1 | View and paginate file1 |
file file1 | Get type of file1 |
head file1 | Show first 10 lines of file1 |
tail file1 | Show last 10 lines of file1 |
tail -F file1 | Output last lines of file1 as it changes |
Search Files
grep pattern files | Search for pattern in files |
grep -i | Case insensitive search |
grep -r | Recursive search |
grep -v | Inverted search |
grep -o | Show matched part of file only |
find /dir/ -name name* | Find files starting with name in dir |
find /dir/ -user name | Find files owned by name in dir |
find /dir/ -mmin num | Find files modifed less than num minutes ago in dir |
whereis command | Find binary / source / manual for command |
locate file | Find file (quick search of system index) |
ls Options
-a | Show all (including hidden) |
-R | Recursive list |
-r | Reverse order |
-t | Sort by last modified |
-S | Sort by file size |
-l | Long listing format |
-1 | One file per line |
-m | Comma-separated output |
-Q | Quoted output |
Command Lists
cmd1 ; cmd2 | Run cmd1 then cmd2 |
cmd1 && cmd2 | Run cmd2 if cmd1 is successful |
cmd1 || cmd2 | Run cmd2 if cmd1 is not successful |
Pipes
cmd1 | cmd2 | stdout of cmd1 to cmd2 |
cmd1 |& cmd2 | stderr of cmd1 to cmd2 |
Bash Commands
| Show system and kernel |
| Show distribution |
| Show mounted filesystems |
| Show system date |
| Show uptime |
| Show your username |
| Show manual for command |
Bash - IO Redirections
cmd > file Redirige stdout de cmd dans file |
cmd 2> file Redirige stderr de cmd dans file |
cmd &> file Redirige stdout et sterr de cmd dans file |
cmd < file Envoi le contenu de file dans cmd |
cmd 2> /dev/null Redirige sterr dans un trou noir |
cmd > file.out 2> file.err Redirige stdout dans file.out et stderr dans file.err |
cmd1 | cmd2 Redirection stdout de cmd1 dans stdin de cmd2. stderr n'est pas transmit dans les | |
cmd1 | cmd2 | cmd3 | cmd4; echo ${PIPESTATUS[@]} Suite de redirections et récupération des |
> file Vide et/ou crée un fichier |
cmd | tee cmd.out | sort | tee sort.out | uniq -c | tee uniq.out Un fichier de sortie par cmd |
(cmd1; cmd2) > file stdout des 2 cmd dans file (via sous shell) |
{ cmd1; cmd2; } > file stdout des 2 cmd dans file (sans sous shell) |
cmd1; cmd2 Execution cmd1 puis cmd2 |
cmd1 && cmd2 Execution de cmd2 si cmd1 est OK |
cmd1 || cmd2 Execution de cmd2 si cmd1 est non OK |
>> ajoute au lieu de rediriger.
Bash - Deplacement
^a | Aller en début de ligne |
^e | Aller en fin de ligne |
%b | Aller au mot précédent |
%f | Aller au mout suivant |
^xx | Alterne le curseur avec sa position précédente |
^p | Historique précédent |
^n | Historique suivant |
^ : Ctrl
% : Alt ou Esc
% : Alt ou Esc
Bash - Variables
${var} Valeur de var |
${var:-word} Affiche word si var est nulle ou unset |
${var:=word} Affiche word si var est nulle ou unset et set assigne word à var |
${var:?} Affiche une erreur si VAR est nulle ou unset |
${var:+word} Affiche word si var est différente de nulle |
${var:offset} Affiche var à partir de l'offset |
${var:offset:lenght} Affiche var à partir de l'offset sur lenght de longeur |
${!tab[@]} Liste les id du tableau tab |
${tab[#_ID]} Affiche la valeur du #_ID de tab |
${#var} Affiche la taille de var |
${var#pattern} var amputé du pattern mini en prefix |
${var##pattern} var amputé du pattern max en prefix |
${var%pattern} var amputé du pattern mini en suffix |
${var%%pattern} var amputé du pattern max en suffix |
${var/pattern/string} Substitution |
${var^} Maj du premier caractère |
${var^^} Maj de tous les caractères |
${var,} Min du premier caractère |
${var,,} Min de tous les caractères |
Bash - Divers
%r | Vide la ligne |
^r | Recherche une commande déjà tapée |
^c | Arrête la commande en court |
^d | Quitte le shell en court |
^l | Efface le contenu de l'écran |
^o | Valide la ligne en cours |
tab | Complétion |
%* | Affiche les complétions disponibles |
Bash - Historique
!! Relancer la dernière commande |
!p Relancer la dernière commande commençant par p |
!l:p Afficher la dernière commande commençant par l |
!$ Récupérer le dernier argument de la commande précédente |
!^ Récupérer le premier argument de la commande précédente |
!* Tous les arguments de la dernière commande |
!*:p idem mais l'affiche |
!n Execute la nième commande |
history -c Vider l'historique |
!-2 Execute la nième commande en partant de la fin |
!?pattern Execute la dernière commande contenant pattern |
pattern1pattern2 Remplace pattern1 par pattern2 dans la dernière commande |
Bash - Edition
^k | Coupe du curseur jusqu'à la fin de ligne |
^u | Coupe du curseur jusqu'en début de ligne |
^w | Coupe le mot avant le curseur |
^y | Coller une chaîne précédemment coupée |
%Backspace | Supprime un mot jusqu’à un symbole de type tiret... |
%d | Supprime le mot suivant |
^h | Remplace Backspace |
%c | Met la première lettre en maj et avance d'un mot |
%u | Met le mot en majuscule |
%l | Met le mot en minuscule |
%. | Réécrit le paramètre de la dernière commande |
%t | Inverse la position des deux mots avant le curseur |
^t | Inverse la position des deux caractères avant le curseur |
^ : Ctrl
% : Alt
% : Alt
/etc/network/interfaces
|
Template for static & dhcp
Bring interfaces up & down
|
Interface Info
|
general ip & interface info
Stack Operations
push source | Insert Value onto the stack |
pop dest | Remove value from stack |
Stack is a LIFO-Storage (Last In First Out)
Mnemonics Intel
| Moves Data |
| Add value to dest |
| Subtract value3 from dest* |
| Increment dest |
| Decrement dest |
| Multiply EAX and src |
| dest = dest * source |
General Structure:
[label] mnemonic [operands] [;comment]
Control / Jumps (signed Int)
| Compare op1 with op2 |
| bitwise comparison |
| unconditional Jump |
| Jump if equal |
| Jump if not equal |
| Jump if zero |
| Jump if not zero |
| Jump if greater |
| Jump if greater or equal |
| Jump if less |
| Jump if less or equal |
For unsigned Integer use
ja, jae
(above) or jb, jbe
(below)Logical Operations
| two-Complement |
| invert each bit |
| dest= dest source |
| dest=dest source |
| dest = dest XOR source |
Misc
| call Interrup Nr |
| jumps to label |
| returns to call |
| no operation |
| load effective addr. to dest |
int 0x80
calls the Kernel in LinuxExample
|
NASM Code-Sections
.text | Code |
.data | initialized Data |
.bss | uninitialized Data |
Syscall-Numbers Linux
EAX | Name(EBX, ECX, EDX) |
1 | exit( int) |
2 | fork( pointer) |
3 | read( uint, char*, int) |
4 | write( uint, char*, int) |
5 | open( char *, int, int) |
Compiling a Code
|
in 64bit Architecture use -f elf64
NASM Basics
-f | filesystem |
-g | debugginfos |
-o | output |
Segment- Registers
ECS | Code-Segment |
EDS | Data-Segment |
ESS | Stack-Segment |
EES | Extra-Segment |
Index-Registers
ESI | Source Index |
EDI | Destination Index |
Pointer-Registers
ESP | Stackpointer |
EBP | Basepointer |
EIP | Instructionpointer |
General Registers
EAX | Accumulator |
EBX | Base |
ECX | Counter |
EDX | Data |
General Registers: specific values are expected when calling the kernel.
Debugging Properties
command_start | returns cmd used to start up minecraft |
command_debug | returns command_start without using screen |
command_archive | returns cmd to archive a server |
command_backup | returns cmd to create rdiff-backup increment |
command_kill | returns cmd to kill a java instance |
command_restore [step] [--force] | returns cmd to restore from an rdiff-backup increment |
command_prune | returns cmd to remove oldest incremental backups |
command_list_increments | returns cmd to list available increments |
command_delete_server | returns cmd to remove specific server files |
Available Properties
up | true if the server is running |
profile | profile the server is assigned |
server_version | minecraft version, e.g., 1.7.9 |
java_pid | process id of java instance |
screen_pid | process id of screen instance |
port | port server is assigned |
ip_address | ip_address server is assigned |
memory | MB used by java (VmRSS) |
ping | returns server info (motd, online players, capacity) |
sp | server.properties |
sc | server.config |
server_type | type of server suite, e.g., bukkit/forge |
ping_debug | show debugging info for web-ui problems |
Available Commands
start | starts a server |
kill | force kills a server |
commit | send 'save-all' to console |
stop | send 'stop' command to console |
archive | creates timestamped, gzipped tarball |
backup | creates an rdiff-backup incremental snapshot |
restore [step] | restores a downed server to a previous incremental backup |
prune [step] | removes old rdiff-backup data and metadata |
delete_server | deletes archive, backup, and live server data |
mineos_console.py commands
console | send text to the game console |
screen | alias to 'console' |
[command] | command to execute on server |
[property] | return value of property |
"-s " means command will execute on specified server.
./mineos_console.py -s [servername] [command/property]
no "-s" means command will iterate on all servers
./mineos_console.py [command/property]
./mineos_console.py -s [servername] [command/property]
no "-s" means command will iterate on all servers
./mineos_console.py [command/property]
mineos_console.py parameters
cmd | the command to execute |
-s | the server to act upon |
-d | the base of the mc file structure |
--this | auto populates -d and -s |
argv | additional arguments to pass |
./mineos_console.py -d /var/games/minecraft -s [myserver] [start]
./mineos_console.py --this [start]
./mineos_console.py --this [start]
Environments
env | display environments variables |
<variable name> = <var. content> | set a shell variable |
export <variable name> = <var. content> | create subshell with env variables |
source <file name> | akes available the variable in the file for the current shell |
echo ${<variable name>} | display the variables content |
export <variable name> | send the variable to the subshells |
Processes
ps -ef | show processes |
ps aux | alternative version, useful for mem . info |
top or htop (if installed) | show resources |
ipcs -m | processes shared memory |
kill <PID> | kill a process |
lsof | tands for LiSt Open Files and shows open files and which process uses them |
lsof -Pp <pid> | file list used by the process <pid> |
lsof -Pp <pid> | grep log | search for the log related to <pid> |
PC details and monitoring
cat /proc/meminfo | ram info |
cat /proc/cpuinfo | cpu info |
lshw | other info about the PC |
memstat 1 | real time of values |
vmstat 1 | Virtual memory stat. |
iostat 1 | IO metrics, realtime |
iotop | similar to iostat |
top or htop (if installed) | show resources |
ipcs -m | processes shared memory |
Main Directories
/etc | configuration files |
/var/log | log files |
/tmp | temp. files |
/home/<user> | home directory |
which <command name> | find an executable |
File Permission
chmod <nmz> <filename> | update the file permission |
chown <new owner username> <filename> | update file owner |
umask | show default mask |
File navigation and Basic Operations
pwd | print working directory |
cd <path> | change driectory to <path> cd ~ |
ls -lrt | directory file list with details |
touch | create a file |
mv <path1+filename> <path2> | move the file in path1 to path2, it can used to rename file |
cp <path1+filename> <path2> | copy, same as above |
file <filename> | show the file-type |
ls -lrt <filename> | details about the file |
stat <filename> | |
tail -f | show last rows of the file and keep update (live mnonitoring) |
vi <filname> | open the file with vi editor |
Basic
man <command name> | help about the command |
<command A> | <command B> | send output of A in input to B |
<nomecomando> & | execute in background |
jobs | show all the background |
nohub <comando> <filename> | launch and protect the process |
w | show the session |
fg %1 | return to foreground |
cat <filename> | print the content of file in the terminal |
iptables
#iptables -L Displays ruleset of iptables |
#iptables -I INPUT -p tcp -m tcp -s 192.168.15.254/26 --dport 22 -j ACCEPT Accepts incoming SSH connections from IP range 192.168.15.254/26 |
#iptables -I INPUT -s "192.168.10.0/24" -j DROP Drops all traffic from IP range 192.168.10.0/24 |
#iptables -A INPUT -p tcp --dport 25 -j DROP Blocks all traffic to TCP port 25 |
#/etc/init.d/iptables save Saves all IPtables rules and re-applies them after a reboot |
Screen shortcuts
CTRL-a c | Create a new screen session |
CTRL-a n | Goto the next screen session |
CTRL-a p | Goto the previous screen session |
CTRL-a " | Present a list of all sessions |
CTRL-a d | Detach screen from terminal |
CTRL-a k | Kill current session |
screen -r to reattach to a detached session
Archiving
|
File Paths
/var/named Bind zone files |
/etc/named.conf Bind configuration file |
/etc/httpd/conf/httpd.conf Main apache configuration file |
/var/log/httpd/ Default location for logs |
/etc/hosts System hosts file |
/etc/resolv.conf DNS lookup configuration file |
/etc/sysconfig/network Network/hostname configuration file |
/etc/sysconfig/network-scripts/ Default location of a network setting file |
Useful Snippets
#hostname Displays FQDN of system |
#uname -a Displays current kernel version |
#df -h Display partitions, sizes details, and mount points |
#chconfig --list Displays all services and their status at each runlevel |
Bash Shortcuts
CTRL-c | Kill current command |
CTRL-a | Goto start of current line |
CTRL-e | Goto end of current line |
CTRL-r | Search history |
!! | Repeat last command |
^abc^def | Run previous command, replacing abc with def |
File Management
find / -name tofind | Find all files named tofind |
find / -mmin 10 | Find all files modified less than 10 minutes ago |
grep -i STRING | Search input for lines containing STRING (nocase) |
grep -C 2 STRING | Search input for lines containing STRING and showing 2 lines before and after |
grep -v STRING | Search input for lines NOT containing STRING |
grep -c STRING | Search input for number of lines containing STRING |
Scheduling with cron
|
I/O Redirection
> | Redirect STDOUT to a file |
2> | Redirect STERR to a file |
&> | Redirect all output to a file |
2>&1 | Redirect all output to a pipe |
cmd1 | cmd2 | Pipe STDOUT of cmd1 to cmd2 |
Use >> to append rather than overwrite
Text Editing
Shortcut | Action |
Ctrl+Left/Right | Next Word Left/Right |
Ctrl+Backspace | Delete Word Left |
Ctrl+Del | Delete Word Right |
Ctrl+Alt+U | Capitalize (Convert to Title Case) |
Ctrl+U | Convert to CapsLock |
Ctrl+Meta+U | Convert to Lowercase (custom) |
F3 | Find Next |
Shift+F3 | Find Previous |
Ctrl+J | Move Cursor Left (custom) |
Ctrl+K | Move Cursor Right (custom) |
Ctrl+T | Transpose Characters Beside Cursor |
Code Editing
Shortcut | Action |
Ctrl+Alt+R | Rename Declaration |
Ctrl+Alt+F | Find/Replace in All Files |
Ctrl+D | Comment |
Ctrl+Shift+D | Uncomment |
Alt+D | Toggle Comment |
Ctrl+Shift+J | Join Lines (custom) |
Alt+Shift+Up/Down | Move to Previous/Next Matching Indent |
Miscellaneous
Shortcut | Action |
F8 | Save All and Compile Project |
Meta+Ctrl+B | Toggle Bottom Dock |
Meta+Ctrl+L | Toggle Left Dock |
Ctrl+Shift+L | Split Window Left/Right (Ctrl+W to Close) |
Ctrl+Shift+P/N | Switch to Previous/Next Split View |
File Navigation
Shortcut | Action |
Ctrl+Alt+N | Outline |
Ctrl+Alt+PgUp/PgDown | Previous/Next Function |
Meta+Shift+F | Find Uses |
Meta+Shift+Left/Right | Previous/Next Use |
Ctrl+G | Go to Line by Number |
Ctrl+Home/End | Go to Beginning/End of Document |
Project Navigation
Shortcut | Action |
Ctrl+Shift+C | Switch Declaration/Definition |
Ctrl+Alt+O | Quick Open File |
Ctrl+Alt+M | Quick Open Function (in any file) |
Alt+Shift+Left/Right | Move Between Tabs |
Credits
This content has been taken from http://tools.rapidsoft.de/perc/perc-cheat-sheet.html with sincere thanks to the author for distilling the information into a usable format. The original author is: Moritz Mertinkat moritz AT mertinkat DOT net |
Please Note
This emergency cheat sheet is not exhaustive, but it should be sufficient in most cases. For a complete reference either call MegaCli -h or refer to the manual at: http://www.lsi.com/files/docs/techdocs/storage_stand_prod/sas/mr_sas_sw_ug.pdf (Chapter 3 – MegaRAID Command Tool). |
Walkthrough: Change/replace a drive
1. Set the drive offline, if it is not already offline due to an error MegaCli -PDOffline -PhysDrv [E:S] -aN 2. Mark the drive as missing MegaCli -PDMarkMissing -PhysDrv [E:S] -aN 3. Prepare drive for removal MegaCli -PDPrpRmv -PhysDrv [E:S] -aN 4. Change/replace the drive 5. If you’re using hot spares then the replaced drive should become your new hot spare drive MegaCli -PDHSP -Set -PhysDrv [E:S] -aN 6. In case you’re not working with hot spares, you must re-add the new drive to your RAID virtual drive and start the rebuilding MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN MegaCli -PDRbld -Start -PhysDrv [E:S] -aN |
Hot spare management
Set global hot spare |
MegaCli -PDHSP -Set -PhysDrv [E:S] -aN |
Remove hot spare |
MegaCli -PDHSP -Rmv -PhysDrv [E:S] -aN |
Set dedicated hot spare |
MegaCli -PDHSP -Set -Dedicated -ArrayN,M,... -PhysDrv [E:S] -aN |
Physical drive management
Set state to offline |
MegaCli -PDOffline -PhysDrv [E:S] -aN |
Set state to online |
MegaCli -PDOnline -PhysDrv [E:S] -aN |
Mark as missing |
MegaCli -PDMarkMissing -PhysDrv [E:S] -aN |
Prepare for removal |
MegaCli -PdPrpRmv -PhysDrv [E:S] -aN |
Replace missing drive |
MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN |
Rebuild drive start |
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN |
Rebuild drive stop |
MegaCli -PDRbld -Stop -PhysDrv [E:S] -aN |
Rebuild drive progress |
MegaCli -PDRbld -ShowProg -PhysDrv [E:S] -aN |
Clear drive start |
MegaCli -PDClear -Start -PhysDrv [E:S] -aN |
Clear drive stop |
MegaCli -PDClear -Stop -PhysDrv [E:S] -aN |
Clear drive progress |
MegaCli -PDClear -ShowProg -PhysDrv [E:S] -aN |
Bad to good |
MegaCli -PDMakeGood -PhysDrv[E:S] -aN |
Virtual drive management
Create RAID 0, 1, 5 drive |
MegaCli -CfgLdAdd -r(0|1|5) [E:S, E:S, ...] -aN |
Create RAID 10 drive |
MegaCli -CfgSpanAdd -r10 -Array0[E:S,E:S] -Array1[E:S,E:S] -aN |
Remove drive |
MegaCli -CfgLdDel -Lx -aN |
Controller management
Silence active alarm |
MegaCli -AdpSetProp AlarmSilence -aALL |
Disable alarm |
MegaCli -AdpSetProp AlarmDsbl -aALL |
Enable alarm |
MegaCli -AdpSetProp AlarmEnbl -aALL |
Gather information
Adapter information |
MegaCli -AdpAllInfo -aALL |
Configuration information |
MegaCli -CfgDsply -aALL |
Events Information |
MegaCli -AdpEventLog -GetEvents -f events.log -aALL && cat events.log |
Enclosure information |
MegaCli -EncInfo -aALL |
Virtual drive information |
MegaCli -LDInfo -Lall -aALL |
Physical drive list |
MegaCli -PDList -aALL |
Physical drive list |
MegaCli -PDInfo -PhysDrv [E:S] -aALL |
Battery backup information |
MegaCli -AdpBbuCmd -aALL |
MegaCli conventions
Adapter parameter -aN |
The parameter -aN (where N is a number starting with zero or the string ALL) specifies the PERC5/i adapter ID. If you have only one controller it’s safe to use ALL instead of a specific ID, but you’re encouraged to use the ID for everything that makes changes to your RAID configuration. |
Physical drive parameter -PhysDrv [E:S] |
For commands that operate on one or more pysical drives, the -PhysDrv [E:S] parameter is used, where E is the enclosure device ID in which the drive resides and S the slot number (starting with zero). You can get the enclosure device ID using „MegaCli -EncInfo -aALL“. The E:S syntax is also used for specifying the physical drives when creating a new RAID virtual drive (see 5). |
Virtual drive parameter -Lx |
The parameter -Lx is used for specifying the virtual drive (where x is a number starting with zero or the string all). |
Requirements and General Information
DELL’s PowerEdge RAID Controller (PERC) is a special LSI Logic SAS/SATA RAID Controller and thus the LSI management utility called MegaCli also works for this controller. For older controllers like PERC4 and PERC3 please refer to http://linux.dell.com/storage.shtml (keyword DellMgr). MegaCli is available for Linux, DOS, Windows, Netware and Solaris. You can get it from LSI’s website (search for MegaRAID SAS) or download it here: http://www.lsi.com/support/downloads/megaraid/miscellaneous/linux/1.01.40_Linux_Cli.zip. Inside the ZIP file you’ll find an RPM archive which contains the MegaCli and MegaCli64 binaries (will be installed to /opt/MegaRAID/MegaCli). |
tmux info
? | list bindings |
Set pane title | printf '\033]2;%s\033\\' 'title goes here' |
Advanced Pane Handling
<space> | toggle through layouts | ||
break-pane | take a pane and make own window | -d | focus stays |
resize-pane | resize pane down | (20) | by 20 cells |
-U (20) | resize up (by 20 cells) | ||
-L (20) | resize left (by 20 cells) | ||
-R (20) | resize right (by 20 cells) | ||
-t 2 20 | pane with id 2 down by 20 | ||
... |
Basic Pane Handling
v | split vertically |
: split-window | split horizontally |
o | go to next pane (down-pane) |
q | show pane number, press number to go to |
{ | move current pane left |
} | move current pane right |
x | kill pane |
Vim like commands
bind s split-window -v | splitting |
bind v split-window -h | splitting |
bind h select-pane -L | motion keys |
bind j select-pane -D | motion keys |
bind k select-pane -U | motion keys |
bind l select-pane -R | motion keys |
setw -g mode-keys vi | vim motion keys while in copy mode |
bind - resize-pane -D 1 | resize pane down by 1 |
bind + resize-pane -U 1 | resize pane up by 1 |
bind < resize-pane -L 1 | resize pane to left by 1 |
bind > resize-pane -R 1 | resize pane to right by 1 |
Pane Window Handling
:joinp -s :2 | move window 2 into a new pane in the current window |
:joinp -t :1 | move the current pane into a new pane in window 1 |
Advanced Window Handling
move-window [ −d] [ −s src-window] [ −t dst-window] |
swap-window [ -d] [ -s src-window] [ -t dst-window] |
Basic Window Handling
c | new window |
, | rename window |
n | next window |
p | previous window |
l | previously selected window |
w | list all windows |
[0-9] | move to window number [0-9] |
f [window name] | find window |
: list-windows | list windows |
& | kill window |
. | move window |
customizing tmux
set-option -g prefix C-a | rebind the Ctrl-b prefix to Ctrl-a | -g for global => every window |
bind-key C-a last-window | switch to last active window | To use hit Ctrl-a twice |
unbind % | Remove default split binding | |
bind | split-window -h | bind vertical splitting to | | |
bind – split-window -v | bind horizontal splitting to - | |
set -g status-bg black | ||
set -g status-fg white | ||
set -g status-left ‘#[fg=green]#H’ | beginning of statusbar hostname in green | |
set-window-option -g window-status-current-bg red | current window shown in red | |
set -g status-right ‘#[fg=yellow]#(uptime | cut -d “,” -f 2-)’ | number of users and load average for computer | |
setw -g monitor-activity on | highlight window with new activity | |
set -g visual-activity on | show info on new activity | |
setw -g automatic-rename on | set window title to current command |
Session handling
tmux | start new |
tmux new -s myname | start new with name |
tmux a -t | reattach session (or at, or attach) |
tmux a -t myname | reattach named session |
tmux ls | list sessions |
tmux kill-session -t myname | kill named session |
:new | new session |
s | list sessions |
$ | name session |
tmux kill-server | kill server and all sessions |
General
Control-a | prefix key (default C-b) |
: | interactive dialog (promt) |
d | detach session |
tmux restore | restore session |
: source-file ~/.tmux.conf | reload .tmux.conf |
t | big clock |
? | list bindings |