Linux Notes, linux stuff, bash, commands reference, Linux How-to's, etc.
Last Updated: August 10, 2018 by Pepe Sandoval
If you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me create more stuff and fix the existent content...
User usable programs and data. User System Resources
stdio.h, stdlib.h stdint.h, etc. are here./usr/bin and /usr/binContains those shared libraries needed to boot the system and run the commands/programs in the root filesystem (binaries in /bin and /sbin folders). Kernel modules (device drivers) are under /lib.
/proc is a "pseudo" file system that exists only in kernel memory and is used primarily for querying various per-process as well as kernel statistics, contains processes as subdirs
/proc/iomem - This file shows you the current map of the system's memory for each physical device:
/proc/<pid>/status: check status of a process
type to know how a command will be interpretedtype -a <command>type -a echohelp <command> to get help informationenable -a: show built-in shell commandsecho $0 or echo $SHELLmkdir -p testdirs/{test1,test2,test3}?: ls tes?t*: ls tes*ls test[123]$(): echo "the current dir is: $(pwd)"GRUB_DEFAULT=0 on the /etc/default/grub file and the run update-grubfor i in `seq 1 10`; do echo $i; donefor (( i=0; i <= $upperlim; i++ )); do
echo "$i"
done
while [ $cnt -gt 0 ]
do
echo "Welcome $cnt times"
cnt=$(( $cnt - 1 ))
done
printf "Message no color, \033[0;36mMessage color\033[0m\n"<groups-letters> user - group - others<permissions-letters> read - write - executechmod <groups-letters> + <permissions-letters> <file>chmod u+rwx,g+rx,o+rx test1chmod 755 test1chmod u+x myscript.shssh -t <user>@<host> '<bash_command_here>; <shell_name>'ssh -t jose@127.0.0.1 'echo Hello; bash'sudo apt-get install openssh-serversudo service ssh statussudo service ssh restartsudo ufw allow 22scp -r <path_to_local_folder> <host_user_here>@<host_dest_ip>:<host_dest_folder>scp -r content/ root@10.219.85.238:/homescp -P 40XX -r content/ root@10.219.85.238:/homersync <source_folder> <dest_folder>rsync -vP <source_file> <dest_file>rsync -azhP --exclude=".*" <source_folder> <dest_folder>rsync -azhP --exclude=".*" <source_folder> <dest_user>@<dest_ip>:<dest_folder>ssh-keygen -t rsaeval ssh-agent -sssh-add -lssh-add ~/.ssh/id_rsassh-keygen -i -f id_dsa_1024_a.pub >> ~/.ssh/authorized_keysopenssl enc -aes-256-ofb -in user.md -out user.encopenssl enc -aes-256-ofb -d -in user.enc -out user.mdopenssl enc -pbkdf2 -in user.md -out user.md.encopenssl enc -pbkdf2 -d -in user.md.enc -out user.mdmd5sum <path_to_file>apt-get install debian-archive-keyring
apt-key update
date --set="YYYYMMDD HH:MM:SS"date --set="20150716 14:36:00"find <path_to_search> -name <search_filename_here>find /usr/include -name stdio.hfind <path_to_search> -type <type_indicator> -iname "search_pattern_here"find ./ -type f -iname "myfile"find / -type d \( -path <path to exclude> \) -prune -o -type <type_indicator> -iname "search_pattern_here"find / -type d \( -path /root/ \) -prune -o -type f -iname "myjsonfile.json"find . -exec touch {} \;find . -type f -name "*.md" | sortgit ls-files -m | sortls -alt | wc -lgit ls-files -m | wc -lfind . -type f -name "*.md" | wc -lfind . -type f -name "*.md" -exec sed -i '' -e 's|\./img\/\(.*\.[[:alpha:]]*\)|https://firebasestorage.googleapis.com/v0/b/pepedocs-ecf95.appspot.com/o/\1?alt=media|g' {} \;grep -rIn <pattern_to_search> <path_to_search>grep -rIn "#include <stdio.h>" ./grep -rIn main ./cat /etc/issuelsb_release -auname -adpkg --print-architecturearchvmstat - reports memory-usage statisticsvmstat <interval> <num_reports> e.g. vmstat 1 3netstat - reports statistics for network interfacesiostat - reports I/O usage for diskstrace - traces system calls invoked by a processtcpdump - collects network packets-w option to monitor (-H is just for human readable)dmesg -wH >> kernel.logdmesg -wHdmesg -CCheck process ID (pid with) ps command
ps -aux | grep "sshd"ps -dN | grep pts/0ps -futopUse kill command to kill process
kill -l: show sigspec listkill <pid>kill 9 <pid> or kill -SIGKILL <pid>kill -<signal name/number> <pid>| Sig Name | Number | Description |
|---|---|---|
| SIGHUP | 1 | Hang-up (POSIX) |
| SIGINT | 2 | Terminal interrupt (ANSI) |
| SIGQUIT | 3 | Terminal quit (POSIX) |
| SIGILL | 4 | Illegal instruction (ANSI) |
| SIGTRAP | 5 | Trace trap (POSIX) |
| SIGIOT | 6 | IOT Trap (4.2 BSD) |
| SIGBUS | 7 | BUS error (4.2 BSD) |
| SIGFPE | 8 | Floating point exception (ANSI) |
| SIGKILL | 9 | Kill (can't be caught or ignored) (POSIX) |
| SIGUSR1 | 10 | User defined signal 1 (POSIX) |
| SIGSEGV | 11 | Invalid memory segment access (ANSI) |
| SIGUSR2 | 12 | User defined signal 2 (POSIX) |
| SIGPIPE | 13 | Write on a pipe with no reader, Broken pipe (POSIX) |
| SIGALRM | 14 | Alarm clock (POSIX) |
| SIGTERM | 15 | Termination (ANSI) |
| SIGSTKFLT | 16 | Stack fault |
| SIGCHLD | 17 | Child process has stopped or exited, changed (POSIX) |
| SIGCONT | 18 | Continue executing, if stopped (POSIX) |
| SIGSTOP | 19 | Stop executing(can't be caught or ignored) (POSIX) |
| SIGTSTP | 20 | Terminal stop signal (POSIX) |
| SIGTTIN | 21 | Background process trying to read, from TTY (POSIX) |
| SIGTTOU | 22 | Background process trying to write, to TTY (POSIX) |
| SIGURG | 23 | Urgent condition on socket (4.2 BSD) |
| SIGXCPU | 24 | CPU limit exceeded (4.2 BSD) |
| SIGXFSZ | 25 | File size limit exceeded (4.2 BSD) |
| SIGVTALRM | 26 | Virtual alarm clock (4.2 BSD) |
| SIGPROF | 27 | Profiling alarm clock (4.2 BSD) |
| SIGWINCH | 28 | Window size change (4.3 BSD, Sun) |
| SIGIO | 29 | I/O now possible (4.2 BSD) |
| SIGPWR | 30 | Power failure restart (System V) |
apt-get install debhelper dpkg-dev binutils
dpkg-buildpackage -rfakeroot -Tcleandpkg-buildpackage -bdnf install fedora-packager after build check -> /root/rpmbuild/RPMS/
rpmbuild -bb --build-in-place specs/*.specsetxkbmap -queryalt+shift: to toggle keybordssetxkbmap -option grp:alt_shift_toggle us,escat /usr/share/X11/xkb/rules/xorg.xmllsmodinsmod <module>.koinsmod <module>.ko <param1_name>=<param1_value> <param2_name>=<param2_value>rmmod <module>.komodinfo <module>.kolspci -nnn
lspci -d 8086:19f2 -x -v
lspci -d 8086:19f2 -xxx -v
lspci -d 8086:19f2 -vvv
Check Errors and status (+ signs means error is set - means is clear)
lspci -d 8086:19f2 -vvv | grep 'UESta' lspci -d 8086:19f2 -vvv | grep 'Lnk' lspci -d 8086:19f2 -vvv | grep 'DevSta' lspci -d 8086:19f2 -vvv | grep 'CESta'Read config space byte/word/long:
setpci -s <bus>:<dev>.<fun> <offset_hex>.<Size>setpci -s 01:00.0 2.Wsetpci -s 01:00.0 0.Lsetpci -s 01:00.0 8.Bsetpci -d <vid>:<did> <offset_hex>.<Size>setpci -s 0101:0101 2.W (2 bytes)setpci -s 0101:0101 0.L (4 bytes)setpci -s 0101:0101 8.B (1 byte)Write config space byte/word/long is equal to read but use = and the value to write
setpci -s <bus>:<dev>.<fun> <offset_hex>.<Size>=<value>setpci -d <vid>:<did> <offset_hex>.<Size>=<value>dpkg -i <package_name>dpkg -r <package_name>dpkg --get-selections: Show installed packages.dpkg -l: Show installed packages.dpkg -l <package_name>: Show info of a packagedpkg -c <package_name>.deb: Show files in a packagedpkg-deb --contents <package_name>.deb: Show info and files in a packagedpkg -S <path_to_file>: shows which package installed this fileapt-get update && apt-get upgrade: Update repos and upgrade packagesapt-get remove <package_name>apt-get install <package_name>=<package_version>: Install a certain versionapt-get search cache <package_name>: search available packagesapt-cache show <package_name>: show available package informationapt-cache madison <package_name>: show available versions of a packageapt-cache pkgnames --all-names: Show available packages.apt-get install apt-fileapt-file updateapt-file search <file>apt-get update
apt-get install ssmtp mailutils
/etc/ssmtp/ssmtp.conf. Mandatory lines:root=postmaster
mailhub=smtp.gmail.com:587
hostname=<HOSTNAME_OF_DEVICE_HERE>
AuthUser=<YOUR_GMAIL_EMAIL_HERE>
AuthPass=<YOUR_GMAIL_PASSWORD>
UseSTARTTLS=YES
You will need
rootuser permissions to edit/etc/ssmtp/ssmtp.confYou can use thehostnamecommand to get the hostname of your device
/etc/ssmtp/revaliases add a line for each user that will send emailsroot:<YOUR_GMAIL_EMAIL_HERE>:smtp.gmail.com:587
pi:<YOUR_GMAIL_EMAIL_HERE>:smtp.gmail.com:587
Set permissions for SSMTP config file: chmod 774 /etc/ssmtp/ssmtp.conf
Test email command: echo "Test text" | mail -s "Test Mail" mailuser@example.com
Add MAILTO variable at the top of the crontab file MAILTO="<dest_email>" add it as empty to disable cron mail service
Reference: Sending emails from the Raspberry Pi
free -mdf -hdf -Hdffdisk -ldu -h --max_depth=1startxfce4sudo shutdown -h nowreadelf --debug-dump=line <path-to-shared-lib.so>sudo chown -R <username>:<group> <directory>sudo passwd <user_name>aspell -c file.txtsudo dpkg-reconfigure tzdataln -s -f <existing_folder_or_file> <path_and_name_of_existing_soft_link>ln -s <existing_folder_or_file> <path_and_name_of_soft_link>tar -czvf name_for_tar.tar.gz /dir/to/targz/tar -xzvf tar_file.tar.gztar -xzvf tar_file.tar.gz -C /output/dirtar -cvf name_for_tar.tar /dir/to/tar/tar -xvf tar_file.targzip -9 index.phpgzip -d index.php.gzzip name_for_zip.zip folderunzip zip_file.zipsudo service networking stopsudo service networking startsudo service networking restartwnetstatcurl <url>curl -I <url>nslookup <web_site>traceroute <web_site> : response are not accumulative it measures an approx. of time from init point to the reported pointip addr show - view a list of your network devicessudo ip addr add <ip_addr_here> dev <dev_name>sudo ip link set <dev_name> upsudo ip link set <dev_name> downip route showUse nmcli to get the gateway, IP Address and DNS info
nmcli device show <interfacename> | grep IP4nmcli device show enp0s3 | grep IP4Edit the interfaces file sudo vim /etc/network/interfaces. Add the following lines with the appropriate information you got with nmcli
auto enp0s3
iface enp0s3 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
/etc/NetworkManager/NetworkManager.conf:[main]
plugins=ifupdown,keyfile
#dns=dnsmasq
[ifupdown]
managed=true
route -n - view routing tablearp -a - view local arp table/etc/hostname and /etc/hosts filesInstalls Apache, utilities, configuration files, and other items
sudo apt-get install apache2apt-cache show apache2Config files in /etc/apache2
/etc/apache2/apache2.confsudo apt install xrdpinstall dependencies: sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
install VNC server:
sudo apt-get install vnc4serversudo apt-get install x11vnc Create VNC server file. vnc4server: sudo vim /etc/systemd/system/vncserver@:1.service with the following content:
[Unit]
Description=Start VNC server at startup
After=syslog.target network.target
[Service]
Type=forking
#YOUR USER HERE!
User=pepe
PAMName=login
#YOUR USER HERE!
PIDFile=/home/pepe/.vnc/%H%i.pid
#ExecStartPre=/usr/bin/vncserver -kill %i > /dev/null 2>&1
#Change your resolution here
ExecStart=/usr/bin/vncserver -depth 16 -geometry 1920x1080 %i
ExecStop=/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
vncserver # Set password
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-session --session=ubuntu-2d &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
sudo systemctl enable vncserver@:1.servicesudo systemctl start vncserver@:1.servicegsettings set org.gnome.Vino require-encryption falseIf you find the information in this page useful and want to show your support, you can make a donation
Use PayPal
This will help me create more stuff and fix the existent content...