{"id":19775516,"url":"https://github.com/jaredchu/useful-commands","last_synced_at":"2026-02-11T01:02:28.785Z","repository":{"id":94223519,"uuid":"82516187","full_name":"jaredchu/Useful-Commands","owner":"jaredchu","description":"My linux useful commands with simple explanation","archived":false,"fork":false,"pushed_at":"2024-12-25T06:04:53.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T01:06:21.207Z","etag":null,"topics":["command-line","documentation","linux"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredchu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-20T04:20:39.000Z","updated_at":"2024-12-25T06:04:56.000Z","dependencies_parsed_at":"2024-12-25T07:18:47.211Z","dependency_job_id":"1b24b3fb-5249-4472-a036-557fef84535d","html_url":"https://github.com/jaredchu/Useful-Commands","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jaredchu/Useful-Commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredchu%2FUseful-Commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredchu%2FUseful-Commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredchu%2FUseful-Commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredchu%2FUseful-Commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredchu","download_url":"https://codeload.github.com/jaredchu/Useful-Commands/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredchu%2FUseful-Commands/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29323964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T00:34:26.354Z","status":"ssl_error","status_checked_at":"2026-02-11T00:34:09.494Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","documentation","linux"],"created_at":"2024-11-12T05:16:32.433Z","updated_at":"2026-02-11T01:02:28.686Z","avatar_url":"https://github.com/jaredchu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linux Useful Commands\nMy useful commands with simple explaination\n\n# SSH\n## SSH - Keygen\n\n### Generate SSH key\n```\nssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"\n```\nrefs https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/\n\n### Retrieve the public key from a SSH private key\n```\nssh-keygen -y -f ~/.ssh/id_rsa \u003e ~/.ssh/id_rsa.pub\n```\nrefs http://askubuntu.com/questions/53553/how-do-i-retrieve-the-public-key-from-a-ssh-private-key\n\n## SSH - Login \n\n### Login with username \u0026 port\n```\nssh username@ip -p [port-number]\n```\n### Login with Keypem\n```\nchmod 400 key.pem\nssh -i key.pem username@ip -p [port-number]\n```\n### login with rsa\n```\n#backup current id.rsa\nmv ~/.ssh/id.rsa ~/.ssh/id.rsa.bak\nmv ~/.ssh/id.rsa.pub ~/.ssh/id.rsa.pub bak\n\n#copy all rsa to ~/.ssh/\ncp file.rsa ~/.ssh/\n\nssh username@ip -p [port-number]\n```\n## Quick upload file via SSH\n```\ncurl --upload-file ./hello.txt https://transfer.sh/hello.txt\n```\n\n# SCP\n### Copy file from local to remote server\n```\nscp path/to/file.ext username@hostname://path/to/folder/\n```\n# Database\n## PostgreSQL\n### Remote connect\n```\npsql -U username -h hostname/ip/urn database-name\n```\n# File and folder\n### Empty all files in current folder\n```\nfind . -type f -exec sh -c '\u003e{}' \\;\n```\n### Check number of nodes in current \n```\nfor dir in *; do [ -d \"$dir\" ] \u0026\u0026 echo \"$dir\" \u0026\u0026 find \"$dir\" | wc -l; done\n```\n### Chmod all file and folder in current dir\n```\nfind . -type d -exec chmod 755 {} \\;\nfind . -type f -exec chmod 644 {} \\;\n```\n\n# Java\n### Run java spring with port\n```\njava -Dserver.port=$PORT -jar target/file.jar\n```\n# Laravel\n### Install composer in a command\n```\nwget -O - composer-install.sh  https://goo.gl/7Yx7W6 | bash\n```\n### Fix project not run the in first time install\n```\ncp .env.example .env\nphp artisan key:generate\nphp artisan config:cache\n```\n### Update to latest NPM to run `npm run watch`\n```\nsudo npm install -g npm\nsudo npm install -g n\nsudo n stable\n```\n# Mysql\n### Dublicate db in the same server\n```\nmysqldump db_name | mysql new_db_name\n```\n### Dump db in remote server\n```\nmysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name \u003e db_backup.sql\n```\n\n# Mysql on MAC\n### Start MySQL\n```\nsudo /usr/local/mysql/support-files/mysql.server start\n```\n### Stop MySQL\n```\nsudo /usr/local/mysql/support-files/mysql.server stop\n```\n### Restart MySQL\n```\nsudo /usr/local/mysql/support-files/mysql.server restart\n```\n### Reset root password\n```\nsudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables\nmysql -uroot\nUPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';\nFLUSH PRIVILEGES;\nexit\n\nsudo /usr/local/mysql/support-files/mysql.server restart\n```\n# LEMP\n### Install LEMP on AWS AMI\n```\nsudo -i\nwget https://raw.githubusercontent.com/jaredchu/useful-commands/master/aws-php-fcgi.sh\nchmod +x aws-php-fcgi.sh\nnano aws-php-fcgi.sh # edit JC_ROOT_FOLDER\n./aws-php-fcgi.sh\n```\n### Change PHP cli version\n```\nsudo update-alternatives --set php /usr/bin/php5.6\n```\n\n# Sudo\n### Sudo without password prompt\n```\n#/etc/sudoers\n\n# User privilege specification\nroot\tALL=(ALL:ALL) ALL\n\n# Members of the admin group may gain root privileges\n%admin ALL=(ALL) ALL\n\n# Allow members of group sudo to execute any command\n#%sudo\tALL=(ALL:ALL) ALL\n\n%sudo\tALL=(ALL:ALL) NOPASSWD:ALL\n```\n# GIT\n### Recover deleted stash\n```\ngitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )\n```\n### Fix file name too long\n```\ngit config --system core.longpaths true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredchu%2Fuseful-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredchu%2Fuseful-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredchu%2Fuseful-commands/lists"}