Code / Linux Flashcards
What is the Unix command to generate a new SSH key pair?
$ ssh-keygen
What is the command to Grant Administrative Privileges to a new user so that user can run superuser commands by adding sudo
before the command?
$ usermod -aG sudo [username]
What is the command to test nginx’s configuration?
$ sudo nginx -t
What are the commands to list all the users in linux?
Local user information is stored in the /etc/passwd file.
$ less /etc/passwd
Displays entries from databases configured in /etc/nsswitch.conf file, including the passwd database, which can be used to query a list of all users.
$ getent passwd
What is the command to create a user in linux?
Use the -m (–create-home) option to create the user home directory as /home/username:
$ sudo useradd -m username
$ sudo passwd username
What is the PostgreSQL connection url?
postgresql://username:password@localhost/db_name
Reset git cache to untrack files in .gitignore
$ git rm -r –cached .
$ git add .
$ git commit -m “.gitignore is now working”
Change git upstream url
$ git remote set-url new-upstream-url
Commands for getting status, starting, stoping, restarting postgres?
$ sudo /etc/init.d/postgresql-8.3 status
$ sudo /etc/init.d/postgresql-8.3 start
$ sudo /etc/init.d/postgresql-8.3 restart
$ sudo /etc/init.d/postgresql-8.3 stop
Command for listing all the services?
$ service –status-all
Command for describing a table in postgres?
db_name=# \d+ table_name;
How to choose a database in postgres cli?
postgres=# \c database_name;
How to list tables in current database in postgres cli?
db_name=# \dt