Shell
SSH
sshto see if ssh is installed (openssh-client is installed by default)ssh-keygenorssh-keygen -t rsagenerate ssh key by RSA algorithmcat ~/.ssh/id_rsa.pubprint public key (for settings on Github)ssh -T [email protected]testingsudo apt-get install openssh-serverinstall server for incoming ssh connectionsssh-copy-id username@hostnamecopy your ssh key to remote computer to avoid verifying password on every connectionssh username@ipssh login to a remote computer with this ip and usernamessh username@hostnameif mapped this hostname to its ip in /etc/hosts filessh -X username@hostnamelogin with GUI supportssh -p 1234 username@hostnamelogin via port 1234sudo gedit /etc/hostsmodify hosts filesudo gedit /etc/ssh/sshd_configmodify ssh server configuration
Devices and Filesystem
sudo gpartedls -l /dev/ttyS0groups <username>sudo gpasswd -a <username> <groupname>sudo gpasswd -d <username> <groupname>sudo groupadd <newgroupname>sudo usermod -a -G <groupname> <username>lscpu,lsmem,lshwlist CPU, memory, hardware infolsusblist USB deviceslsblklist block devices, often used to check external ssdlspcilist PCI deviceslspci | grep VGAcheck GPUssudo lshw -C videocheck GPU display detailsdu -h -d 1check file size/usage in current directorydf -hcheck hard disk usage
Environment Variables
which pipto see whichpipcommand you are running - useful for checking environment!uncomment
#force_color_prompt=yesin.bashrcfor a colored promptsudo !!where!!is for the last commandpython3 -m siteshow searching path for python3sudo python -m pip install --force-reinstall pip==8.1.1if you inadvertently upgraded your system pip. More info can be found at this link, and this link.sudo ldconfigaftersudo make installto refresh the cache
Date and Time
datesudo systemctl stop systemd-timesyncdsudo systemctl start systemd-timesyncdtimedatectlsudo timedatectl set-ntp falsesudo timedatectl set-time 'YYYY-MM-DD'sudo timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
Network
sudo systemctl restart network-managernmap -sP 192.168.0.1/24scan portsnmap -A 192.168.10.112detect OS and services
Compression
tar -cf filename.tar file1 folder2packed without compressiontar -xf filename.tarcreate an archive by-c, extract an archive by-xtar -cvzf filename.tar.gz file1 folder2compress by-z; verbose by-vtar -xvzf filename.tar.gzdecompresstar -xvzf filename.tar.gz -C {path}decompress to a designated pathsudo apt-get install zip unzipzip -r archive_name.zip myfolderunzip archive_name.zip
running in the background
Ctrl + Zto stop the process, followed bybgto run in the background orfgto run in the foreground.Use command
./test.sh 1>stdout.log 2>stderr.log &and it will return a process ID.Processes running in the background can be monitored by
topcommand.
apt commands to find dependencies (link)
apt-cache showpkg <pkgname>show package info, both depends and reverse dependsapt-cache depends ros-melodic-desktopshow one-level dependenciesapt-cache rdepends --installed ros-melodic-desktopsudo apt install apt-rdependsapt-rdepends ros-melodic-desktop | pagerrecursively show all dependenciesapt-rdepends --reverse protobuf-compiler | grep ros-melodic-desktop
apt commands to locate packages
dpkg -L <package-name>apt list <package-name>apt-cache madisonlocate <filename>find a file in database (globally)find <filename>find a file in local directory
vim commands
vi -b <filename>open file in binary mode:%!xxdswitch to hex mode:%!xxd -rswitch back to binary mode:wqsave and exit
terminal
sudo update-alternatives --config x-terminal-emulator
References
Last updated
Was this helpful?