Code / Linux Flashcards

1
Q

What is the Unix command to generate a new SSH key pair?

A

$ ssh-keygen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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?

A

$ usermod -aG sudo [username]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the command to test nginx’s configuration?

A

$ sudo nginx -t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the commands to list all the users in linux?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the command to create a user in linux?

A

Use the -m (–create-home) option to create the user home directory as /home/username:

$ sudo useradd -m username
$ sudo passwd username

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the PostgreSQL connection url?

A

postgresql://username:password@localhost/db_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Reset git cache to untrack files in .gitignore

A

$ git rm -r –cached .
$ git add .
$ git commit -m “.gitignore is now working”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Change git upstream url

A

$ git remote set-url new-upstream-url

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Commands for getting status, starting, stoping, restarting postgres?

A

$ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Command for listing all the services?

A

$ service –status-all

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Command for describing a table in postgres?

A

db_name=# \d+ table_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to choose a database in postgres cli?

A

postgres=# \c database_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to list tables in current database in postgres cli?

A

db_name=# \dt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly