echo exit | strace bash -li |& grep '^open'
Last active
June 2, 2023 08:53
-
-
Save ryumada/af982219d9de9e03d8f066be6bd0887c to your computer and use it in GitHub Desktop.
Useful Linux Command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===============USEFUL LINUX TERMINAL COMMAND================= | |
OWNERSHIP --------- | |
Change single folder ownership ++++++++++++++++++++++++++++++ | |
chown rizuki-ryumada /opt/lampp/htdocs/hc_system/ | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Change All folder and subfolder ownership +++++++++++++++++++ | |
sudo chown -R rizuki-ryumada /opt/lampp/htdocs/hc_system | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
DEFAULT LINUX OPT FOLDER PERMISSION +++++++++++++++++++++++++ | |
sudo chown root:root /opt | |
sudo chmod 0755 /opt | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Find out which scripts being run by Linux on startup ++++++++ | |
echo exit | strace bash -li |& grep '^open' | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Run Application on debug mode +++++++++++++++++++++++++++++++ | |
dbus-launch <apllication-name> | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Unused Port Check +++++++++++++++++++++++++++++++++++++++++++ | |
netstat -tulpn | grep LISTEN | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
add folder places to system wide path +++++++++++++++++++++++ | |
edit this environment file | |
/etc/environment | |
add path | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
add program to terminal +++++++++++++++++++++++++++++++++++++ | |
FIRST edit this file | |
sudo nano ~/.bashrc | |
then, add this piece of code | |
# enable ngrok repo to be accessed globally | |
export PATH="$PATH:/home/rizuki-ryumada/programs/<scritpt>" | |
last restart your computer, end session, or logout. to make | |
it come true | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
remove directory with its files +++++++++++++++++++++++++++++ | |
rm -r dirname | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
startup manager gnome +++++++++++++++++++++++++++++++++++++++ | |
gnome-session-properties | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
launch tlp battery saver and indicator cpufreq ++++++++++++++ | |
sudo tlp start | |
indicator-cpufreq | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Reset the ownership of the WordPress instillation to nobody + | |
sudo chown -R nobody:staff /directory | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Move file +++++++++++++++++++++++++++++++++++++++++++++++++++ | |
sudo mv -v /home/rizuki-ryumada/Downloads/lynis-2.7.5.tar.gz /usr/local/lynis | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Move File with its files ++++++++++++++++++++++++++++++++++++ | |
mv -v ~/Downloads/* ~/Videos/ | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Webmin - Web Server Administrator web app +++++++++++++++++++ | |
sudo /etc/init.d/webmin start | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Notification for teminal ++++++++++++++++++++++++++++++++++++ | |
alias d="kdialog --title 'Konsole Completed' --passivepopup 'There is a completed konsole task, please check it.'" | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Systemd - autostart and service manager +++++++++++++++++++++ | |
Improving boot time is highly related with disabling/managing service, but the current answers lack details in disabling services which uses systemd. | |
What is systemd? | |
In short, systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. More about this can be read from official project page. | |
Check which services takes most time | |
Use the following command to check which service takes most of time | |
systemd-analyze blame | |
Disabling auto-start of services during boot | |
If you want to disable auto-starting of services during boot you can use the following command | |
sudo systemctl disable some-time-eater-service.service --now | |
However, you might want to see which other services needs the service in question. To check use the following command | |
systemctl list-dependencies some-time-eater-service.service --reverse | |
Note: Replace some-time-eater-service.service with actual service name like [email protected]. | |
Note that, disabling auto-start doesn't make a service non-startable. The service can be started after boot when requirement arises. If you want to completely disable it, read the next section | |
Disabling services completely. | |
If you want to completely disable a service so that it can't be started, you should use mask instead of disable. Like this | |
sudo systemctl mask <SERVICE-NAME> | |
Replace the <SERVICE-NAME> with actual name of a service | |
The difference between mask and disable is mask make a service completely disable, you can't start it. You must unmask to start it with systemd (you can still start with service). But disable simply disable auto-start of a service, you can start it later. | |
For example, After masking my [email protected] service, when I wanted to start it with systemctl the following message is shown | |
Failed to start [email protected]: Unit [email protected] is masked. | |
RESTART KDE PLASMASHELL Desktop ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
In KDE 4, you can do: | |
killall plasma-desktop #to stop it | |
kstart plasma-desktop #to restart it | |
In KDE 5 use: | |
killall plasmashell #to stop it | |
kstart plasmashell #to restart it | |
In KDE > 5.10 use: | |
kquitapp5 plasmashell | |
kstart5 plasmashell | |
Add Hibernate Option | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
source: https://askubuntu.com/a/1316444/1091674 | |
Reduce overheating: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Overheating is a common problem in computers these days. An overheated computer runs quite slow. It takes ages to open a program when your CPU fan is running like Usain Bolt. There are two tools which you can use to reduce overheating and thus get a better system performance in Ubuntu, TLP and CPUFREQ. | |
To install and use TLP, use the following commands in a terminal: | |
sudo add-apt-repository ppa:linrunner/tlp | |
sudo apt-get update | |
sudo apt-get install tlp tlp-rdw | |
sudo tlp start | |
You don’t need to do anything after installing TLP. It works in the background. | |
To install CPUFREQ indicator use the following command: | |
sudo apt-get install indicator-cpufreq | |
Restart your computer and use the Powersave mode in it: | |
AUTO MOUNT DISK +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Guide to mount a drive in linux (deb/ubuntu) and set to auto-mount at boot. | |
Mount drive | |
Make a folder (will be mount point) | |
sudo mkdir /media/data | |
sudo mount /dev/sdb1 /media/data | |
Now you can access the drive at /media/data. | |
Auto-mount at boot | |
We want the drive to auto-mount at boot. This usually means editing /etc/fstab. | |
Firstly, it's always best to use the drives UUID. To find the drive's UUID do | |
ls -al /dev/disk/by-uuid/ | |
Copy the resultant UUID (for your disk) and then open fstab for editing: | |
sudo nano /etc/fstab | |
You want to add an entry for the UUID and mount point. Below is an example of an fstab file with an entry added for the mount above: | |
# /etc/fstab: static file system information. | |
# | |
# Use 'blkid' to print the universally unique identifier for a | |
# device; this may be used with UUID= as a more robust way to name devices | |
# that works even if disks are added and removed. See fstab(5). | |
# | |
# <file system> <mount point> <type> <options> <dump> <pass> | |
# / was on /dev/sdb1 during installation | |
UUID=63a46dce-b895-4c1f-9034-b1104694a956 / ext4 errors=remount-ro 0 1 | |
# swap was on /dev/sdb5 during installation | |
UUID=b9b9ee49-c69c-475b-894b-1279d44034ae none swap sw 0 0 | |
# data drive | |
UUID=19fa40a3-fd17-412f-9063-a29ca0e75f93 /media/data ext4 defaults 0 0 | |
Note: the entry added is the last line. | |
Test fstab | |
We always want to test the fstab before rebooting (an incorrect fstab can render a disk unbootable). To test do: | |
sudo mount -a | |
If nothing is returned (e.g. no errors) then you should be good to go. | |
Unmounting drive with umount | |
You can unmount drives using umount. For example, to unmount the data drive above mount at /media/data you would do: | |
sudo umount /media/data | |
# ----------------- CHANGE OWNERSHIP of MOUNTED Drive on boot ---------------- # | |
For NTFS partitions, use the permissions option in fstab. | |
First unmount the ntfs partition. | |
Identify your partition UUID with blkid | |
sudo blkid | |
Then edit /etc/fstab | |
# Graphical | |
gksu gedit /etc/fstab | |
# Command line | |
sudo -e /etc/fstab | |
And add or edit a line for the ntfs partition | |
# change the "UUID" to your partition UUID | |
UUID=12102C02102CEB83 /media/windows ntfs-3g auto,users,permissions 0 0 | |
Make a mount point (if needed) | |
sudo mkdir /media/windows | |
Now mount the partition | |
mount /media/windows | |
The options I gave you, auto, will automatically mount the partition when you boot and users allows users to mount and umount . | |
You can then use chown and chmod on the ntfs partition. | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= | |
MYSQL server permission settings | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Set an owner, a group and permissions to the correct one: | |
# chown mysql:adm /var/log/mysql/error.log | |
# chown mysql:adm /var/log/mysql | |
# chown root:syslog /var/log | |
# chown root:root /var | |
# chmod 0640 /var/log/mysql/error.log | |
# chmod 0750 /var/log/mysql | |
# chmod 0775 /var/log | |
# chmod 0755 /var | |
sudo chmod 0777 /tmp | |
# ---------------------------------------------------------------------------- # | |
# LINUX PERMISSION # | |
# ---------------------------------------------------------------------------- # | |
# -------------------------- Absolute(Numeric) Mode -------------------------- # | |
In this mode, file permissions are not represented as characters but a three-digit octal number. | |
The table below gives numbers for all for permissions types. | |
Number Permission Type Symbol | |
0 No Permission --- | |
1 Execute --x | |
2 Write -w- | |
3 Execute + Write -wx | |
4 Read r-- | |
5 Read + Execute r-x | |
6 Read + Write rw- | |
7 Read + Write + Execute rwx | |
example : sudo chmod 764 ~/ | |
description: | |
folder : Home Folder (/home/<user-name> | |
set permission : | |
7 = Read + Write + Execute to Owner of the file | |
6 = Read + Write to group owner of file | |
4 = Read to All Other user (World/Anyone else) | |
# ------------------------------- Symbolic Mode ------------------------------ # | |
In the Absolute mode, you change permissions for all 3 owners. In the symbolic mode, you can modify permissions of a specific owner. It makes use of mathematical symbols to modify the file permissions. | |
Operator Description | |
+ Adds a permission to a file or directory | |
- Removes the permission | |
= Sets the permission and overrides the permissions set earlier. | |
The various owners are represented as - | |
User Denotations | |
u user/owner | |
g group | |
o other | |
a all of the 3 typed user (u, g, o) | |
We will not be using permissions in numbers like 755 but characters like rwx. | |
example : sudo chmod o-rwx ~/ | |
description: | |
folder : Home Folder (/home/<user-name> | |
set permission : | |
o = set permission to other (Anyone Else) | |
- = remove permissions | |
r = read attribute | |
w = write attribute | |
x = execute attribute | |
other example : sudo chmod o-r ~/ | |
other example : sudo chmod o-rw ~/ | |
other example : sudo chmod o-wx ~/ | |
other example : sudo chmod o-rx ~/ | |
etc. | |
# ------------------------- change ownership of file ------------------------- # | |
chown user:group filename | |
chown user file-name | |
chgrp group-name file-name | |
groups = to find all the groups you are a member of | |
# ------------ To change all the directories to 755 (drwxr-xr-x): ------------ # | |
sudo find /var/www/html/* -type d -exec chmod 755 {} \; | |
# --------------- To change all the files to 644 (-rw-r--r--): --------------- # | |
sudo find /var/www/html/* -type f -exec chmod 644 {} \; | |
# ------------------------------ ABOUT IPTABLES ------------------------------ # | |
iptables stores its information in RAM, meaning it's non-persistent. If you want to save/restore it at will, you'll need to use a couple commands. | |
First off, you would use iptables as normal to set up your rules the way you want them. Then, you can freeze these rules using something like: | |
sudo iptables-save | sudo tee /etc/iptables.conf | |
Then, to load your rules, it's a simple matter of running: | |
sudo iptables-restore < /etc/iptables.conf | |
You can add this to your /etc/rc.local or similar to have it run automatically at boot, or you can have your program call this executable (or just pass the same iptables rules over and over again). | |
# -------------------- APACHE remove index.php mod_rewrite ------------------- # | |
If you're on Apache, your httpd.conf file probably has AllowOverride None set for your site, effectively disabling all .htaccess file changes. | |
Change it to AllowOverride All, restart Apache and you should finally be set. Also make sure mod_rewrite is enabled. | |
# ----------------------------- APACHE phpmyadmin 404 error ------------------ # | |
add the following line to /etc/apache2/apache.conf | |
Include /etc/phpmyadmin/apache.conf | |
# --------------------------- APACHE 403 FORBIDDEN --------------------------- # | |
look for apache.conf | |
add Listen Port | |
add AllowOverride | |
# ------------------ APACHE DEFAULT PERMISSION for /var/www/ ----------------- # | |
The default permission for /var/www itself is a pretty standard one: owner root:root and mod 755. | |
As for anything inside /var/www, that is one of the rare directories where you have the privilege of deciding for yourself what to put in it and | |
what permissions everything in it should have. But what makes the most sense is: | |
Most files should be writable by whichever user or group is going to be writing to them most. You can set them to be owned by your user | |
account. Or set up a custom group for your developers. Or if the files will be modified rarely and you want good security, you can go with | |
root:root and just sudo in on the rare occasions they'll be modified. | |
Most files should not be world-writable. So, 644 for files, and 755 for directories is appropriate (or 664 and 775 if you want to give a | |
group write access). | |
It is not recommended to set any of it to be writable by the web server, ie www-data, except for any specific files your web scripts to be | |
able to write to. If so, it's better to set the user or group of those files to www-data than to make them world-writable. Note that any time | |
the www-data user can write to any file within the web root, whether it's by setting the user or group on those files, or making them | |
world-writable, it's a potential security problem. World-writable is just the worse of the two. | |
# --------------------- APACHE HOW TO CREATE VIRTUAL HOST fix 403 FORBIDDEN-------------------- # | |
REMEMBER DON'T MAKE VIRTUAL HOST FROM WEBMIN, it will messed up with 403 FORBIDDEN | |
1. copy configuration of default conf to a new one. | |
2. set the document root and alias (actually for alias can be localhost or localhost:<port>) | |
3. set the port | |
4. add AllowOverride on apache.conf | |
5. add new Listen Port to port.conf or apache.conf | |
# ---------------------- MYSQL Login without a password ---------------------- # | |
I'm going to check the obvious first and ask if you remembered to copy your config.sample.inc to config.inc. | |
in most cases on linux you will find config files here: /etc/phpmyadmin/config.inc.php | |
Second, if you are trying to log in as root, you should have the following lines in your config: | |
$cfg['Servers'][$i]['user'] = 'root'; | |
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true; | |
Hope that helps. | |
--DondeEstaMiCulo | |
# -------------------------- MYSQL Remove Completely ------------------------- # | |
Usually this problem appears when you try to change something in the /etc/mysql/my.cnf. | |
WARNING The following solution will delete all your database data! Try other solutions first. | |
Reinstalling MySQL may solve the problem, but should only be used as a last resort! To reinstall: | |
sudo apt purge mysql-server mysql-common | |
sudo apt autoremove mysql-server mysql-common | |
and reinstall it again | |
sudo apt-get update | |
sudo apt-get install mysql-server | |
check this out: https://askubuntu.com/questions/392438/mysql-job-failed-to-start | |
note : This solution will delete all your database data ! So be aware of what you are doing . | |
# ------------------ MYSQL access denied for root@ localhost ----------------- # | |
Can’t log into phpMyAdmin: mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’ | |
Change root Authentication Method | |
In order to log into phpMyAdmin as your root MySQL user, you will need to switch its authentication method from auth_socket to mysql_native_password. | |
Open up the MySQL prompt from your terminal: | |
sudo mysql | |
Run the following query. | |
SELECT user,plugin,host FROM mysql.user WHERE user = 'root'; | |
Output: | |
+------+-------------+-----------+ | |
| user | plugin | host | | |
+------+-------------+-----------+ | |
| root | auth_socket | localhost | | |
+------+-------------+-----------+ | |
1 row in set (0.00 sec) | |
Above we can see that the plugin for the root account is set to auth_socket. You need to change this to mysql_native_password. Also, the host value should be set to localhost or %. If it’s set to anything else, you may not be able to log into phpMyAdmin with root. See: Understanding MySQL Users and Hosts | |
Run the following query to change the plugin value to mysql_native_password. Make sure to replace enter_password_here with your own. Click here if you need to generate a new password. | |
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'enter_password_here'; | |
Flush privileges. | |
FLUSH PRIVILEGES; | |
You should now be able to log into phpMyAdmin using your root account. |
menuentry "Reboot" {
reboot
}
menuentry "Shutdown" {
halt
}
place the code to /etc/grub.d/40_custom
source: https://forums.linuxmint.com/viewtopic.php?t=224592
menuentry 'System setup' {
fwsetup
}
fwsetup
need to be run ingrub-efi
. You should use that instead of using normal grub. In order to enable that before the instalation of you linux distribution, your bootable disk should supportEFI
(there is an efi file or folder) and set boot priority of your system toUEFI First
.
source: https://bbs.archlinux.org/viewtopic.php?id=254013
IF YOU EDIT THE GRUB USING
GRUB CUSTOMIZER
, just add the menuentry command to the other type menuentry.
So for example if you want to add "Reboot" menu to grub set this inside the grub customizer's add menuentry dialog:
- Name : Reboot
- Type : Choose Other
- Boot Sequence :
reboot
Then click Ok
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment