Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
linux:commands [2008/11/27 22:24]
cyril +monitoring
linux:commands [2012/06/10 13:14]
cyril
Line 1: Line 1:
-====== Current Commands ======+====== Usual Commands ======
  
 ===== Links ===== ===== Links =====
Line 15: Line 15:
 | pwd | print the current path | | pwd | print the current path |
 | which <program> | print the path of the <program> | | which <program> | print the path of the <program> |
 +| write <user> | write messages with a user connected on the same machine |
 ^  Kernel modules  ^^ ^  Kernel modules  ^^
 | lsmod | list modules | | lsmod | list modules |
Line 23: Line 24:
 | rc-update add script.sh boot | add the script to the boot level | | rc-update add script.sh boot | add the script to the boot level |
 ^  Manage users  ^^ ^  Manage users  ^^
-| adduser -m -s /bin/zsh -g users cyril | add user cyril, ask creation of his home folder (-m), shell (-s), groups (-g) |+| adduser -m -s /bin/zsh -g <primary-group> <user> | add user, ask creation of his home folder (-m), shell (-s), primary group (-g) |
 | passwd cyril | change the password of user cyril (or yours if no user specified) | | passwd cyril | change the password of user cyril (or yours if no user specified) |
 | groupadd <group> | add a group to the system | | groupadd <group> | add a group to the system |
 | /etc/passwd | contains UID of users, home directory and shell used | | /etc/passwd | contains UID of users, home directory and shell used |
 | /etc/shadow | contains crypted passwords of users | | /etc/shadow | contains crypted passwords of users |
-| /etc/group | contains groups GIDs and list of users in (you can edit it to add users to groups) |+| /etc/group | contains groups GIDs and list of users in 
 +| usermod -a -G <group> <user>add an exisiting user to an existing group | 
 +| chsh -s /bin/zsh | change default shell of user |
 | userdel | delete user | | userdel | delete user |
 | groupdel | delete group | | groupdel | delete group |
 ^  Manage permissions  ^^ ^  Manage permissions  ^^
-| chmod -R [u/g/o/a][+/-/=][r/w/x] <file(s)/folder(s)> | change permissions (user,group,other,all) |+| chmod -R [u/g/o/a][+/-/=][r/w/x/X][,...] <file(s)/folder(s)> | change permissions (user,group,other,all ; read,write,execute,execute clone) |
 | chmod -R 0222 | change permissions (octal : rwx=1+2+4 / ugo) | | chmod -R 0222 | change permissions (octal : rwx=1+2+4 / ugo) |
 | chown -R <owner>:<group> <file(s)/folder(s)> | change owner and group | | chown -R <owner>:<group> <file(s)/folder(s)> | change owner and group |
-^ Monitoring ^^+| chgrp -R <group> <file(s)/folder(s)> | only change group | 
 + Monitoring  ^^
 | top / htop / ps / free | processes (cpu, mem) | | top / htop / ps / free | processes (cpu, mem) |
 | nettop / jnettop | network | | nettop / jnettop | network |
Line 47: Line 51:
 | lshw | | | lshw | |
 ^  File content manipulation  ^^ ^  File content manipulation  ^^
 +| ''cat file | head -n 2'' ,   ''cat file | tail -n 2'' |   |
 | ''cat file | grep <string>'' | only print lines containing string (-e for regexp) | | ''cat file | grep <string>'' | only print lines containing string (-e for regexp) |
 | grep -r <string> * | search recursively the string in all files | | grep -r <string> * | search recursively the string in all files |
 | ''cat <file> | cut -d " " -f 1,2,4-10'' | only prints the given fields (-f), obtained with the given delimiter (-d), or the complement (--complement) | | ''cat <file> | cut -d " " -f 1,2,4-10'' | only prints the given fields (-f), obtained with the given delimiter (-d), or the complement (--complement) |
 | ''cat <file> | sed 's/string1/string2/g'' | replace string1 by string2 (and a lot more with sed) | | ''cat <file> | sed 's/string1/string2/g'' | replace string1 by string2 (and a lot more with sed) |
-| perl -pi -e "s/string1/string2/g" <files> | replace string1 by string2 in all files (and a lot more with perl) |+''sed -i 's/string1/string2/g <files>'' | replace string1 by string2 in all files | 
 +| ''echo "Image 10:55.jpg" | sed 's/([0-9]{2}).jpg/\1 #1.jpg/' '' | example with more complex regex | 
 +| ''perl -pi -e "s/string1/string2/g" <files>'' | replace string1 by string2 in all files (and a lot more with perl) 
 +| ''awk 'NR>10 && NR<1000 {print $#}' <file-in>'' | extract lines 10 to 1000 from file-in to file-out | 
 +| ''awk '{ print "[10]("$1","$4","$5","$6")" }' <file-in>'' | reorganize and reformat columns of a file | 
 +| ''awk 'NR==1 { t=$1 } NR>1 { dt=t-$1; t=$1; print dt; }' <file-in>'' | output the difference between two consecutive lines |
 | ''cat <file> | tr '[:lower:]' '[:upper:]' '' | convert lowercase to uppercase (and a lot more with tr) | | ''cat <file> | tr '[:lower:]' '[:upper:]' '' | convert lowercase to uppercase (and a lot more with tr) |
 +| ''date +"%Y/%m/%d %H:%M:%S" | tr '\012' ' ' >> log.log'' | write date in a file without the last line return |
 | ''cat <file> | wc -l'' | count number of lines (and a lot more with wc) | | ''cat <file> | wc -l'' | count number of lines (and a lot more with wc) |
 | iconv -f iso-8859-15 -t utf8 <file> | convert file content from encoding latin9 to utf8 (see also ''recode'') | | iconv -f iso-8859-15 -t utf8 <file> | convert file content from encoding latin9 to utf8 (see also ''recode'') |
 | convmv -f iso-8859-15 -t utf8 -r <folder> | convert file names of files in folder from encoding latin9 to utf8 | | convmv -f iso-8859-15 -t utf8 -r <folder> | convert file names of files in folder from encoding latin9 to utf8 |
 +| paste | merge files by concatenating columns |
 +^  Programming  ^^
 +| nm [-D] / objdump / ldd / readelf [-s] | check infos about link and symbols in exe and libs |
 +| strace | list system calls a program issues |
 +
 +tr '\012' ' '
linux/commands.txt · Last modified: 2024/04/19 13:59 by cyril
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0