Посмотреть имя пользователя linux

How can I find out my user name?

How do I know my username? I’ve installed Ubuntu, but I don’t know my username, only my password. I can’t access my laptop and it can’t be opened.

The login screen shows possible accounts and you only have to click (or even not have to click since you were presumably the last to log in) and type your password.

@Jayharte — did any of these answers work for you? If so, please accept one as the answer. Thank you.

9 Answers 9

Open a Terminal and type whoami

This will work on every Unix/Linux System.

@rajlego If run from recovery mode, whoami would just output root . However, in recovery mode, ls /home could be used to view the names of the system’s normally configured human users. If there’s just one such user, this output is their username; and even if there are more, it should make it pretty easy to figure out the username.

Agree with @Boris. As he mentioned in the answer, he could not login, how could he launch whoami ? It’s strange to have this answer got many vote-ups.

@TungTran — Upvotes are from googlers (like me) who came here looking for the answer to the question in the title. Some of us just need a reminder of the command that prints out the current username. But, reading the actual question, this answer is pretty useless to the asker.

This will print the value of USER environment variable to the console.

To the original asker, this is as useless as the whoami command, but in all honesty, this is perfect for those «run a blah username_here » commands where username_here part can be replaced with $USER and the whole command made more universal. Thanks.

@Ali Dehghani, $USER is an environment variable that can be changed to anything. whoami actually checks which is the currently logged in user

Most simple way to find out your username is probably to press ctr+alt+t — this opens terminal and than you will see something like:

And that answers your question.

If you installed ubuntu, then you filled in your username, does this help jog our memory?

E.g. here where yann is the user name

Читайте также:  Linux сеть windows общие папки

enter image description here

You should boot up your Ubuntu in recovery mode. Follow the steps below:

  • Switch on your computer. Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.) Quickly press and hold the Shift key, which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you’ve missed the point where you can enter the GRUB menu.) **
  • Select the line which starts with «Advanced options«. *
  • Select the line ending with «(recovery mode)«, probably the second line, something like: Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)
  • Press Return and your machine will begin the boot process.
  • After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be «Drop to root shell prompt«. Press Return with this option highlighted.

Eventually, you could use this command to list all usernames:

I suppose you will be able to recognize your username in the list.

This will work if the user hasn’t set their root password ever. However, if someone has set it already, they can always just use a live usb or any other OS to look at the home directory(hopefully unencrypted.)

Yes, if he remembers his root password, it’s even easier. Anyway, as he said, he’s installed the Ubuntu and doesn’t know his username. I suppose he didn’t set root password.

Normally when you start your computer, you don’t have to know your username to log on, because it appears automatically in a list. And if it’s the only user account, it’s the only name listed. It should look like this:

enter image description here

If there is more than one user account, click on the name you want to use. For just one user, all you have to do is type in your password.

If your login screen does not look like that, or logging in does not work, or the problem is that booting fails before you get to the login screen, please let us know, and provide as many details as possible.

Источник

Получить имя текущего пользователя в Unix/Linux

Хотелось бы рассказать в своей статье «Получить имя текущего пользователя в Unix/Linux» как можно получить имя текущего пользователя в Unix/Linux. Я, использовал только несколько, но нашел еще несколько о которых и не знал.

Самый простой способ получить текущего пользователя — это выполнить следующую команду:

Так же, можно воспользоваться переменным окружением и вывести следующий параметр:

Читайте также:  Error code linux bash

Так же, можно получить пользователя по ID:

Так же, можно получить пользователя по PID:

Можно использовать утилиту «w» и она покажет пользователя:

Вот еще один пример хорошей утилиты:

Вот и все, тема «Получить имя текущего пользователя в Unix/Linux» завершена.

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Рубрики

  • Arch Linux (167)
  • Commands (36)
  • Debian’s (635)
    • Administration tools Ubuntu (37)
    • Backups Debian’s (7)
    • Database в Ubuntu (58)
    • Games (игры) (1)
    • Monitoring в Debian и Ubuntu (49)
    • Virtualization в Ubuntu / Debian/ Linux Mint (41)
      • Docker (22)
      • Kubernetes (6)
      • KVM (4)
      • OpenVZ (3)
      • Vagrant (5)
      • VirtualBox (6)
      • ArgoCD (1)
      • Concourse (1)
      • Gitlab (1)
      • Jenkinks (4)
      • Spinnaker (1)
      • Apache (32)
      • Cherokee (1)
      • FTP-services (5)
      • Lighttpd (1)
      • Nginx (26)
      • PHP (27)
      • Proxy для Debian’s (2)
      • Tomcat (4)
      • Панели управления в Ubuntu/Debian/Mint (24)
      • Установка и настройка почты на Ubuntu/Debian (12)
      • Хранилища (clouds) (2)
      • Administration tools freeBSD (19)
      • Database во FreeBSD (52)
      • Monitoring во freeBSD (37)
      • Virtualization во FreeBSD (22)
      • VoIP (1)
      • Установка Web сервисов (91)
      • Установка и настройка почты (6)
      • Установка из ports (пакетов) (19)
      • Установка из sorce code (исходников) (23)
      • Непрерывная интеграция (CI) (27)
      • Database в MacOS (36)
      • Monitoring в Mac OS (31)
      • Security (безопасность) (12)
      • Virtualization в Mac OS (30)
        • Docker (19)
        • Kubernetes (6)
        • Vagrant (5)
        • VirtualBox (5)
        • ArgoCD (1)
        • CircleCI (1)
        • Concourse (1)
        • Gitlab (1)
        • Jenkinks (4)
        • Spinnaker (1)
        • Administration tools CentOS (49)
        • Backups RPM’s (4)
        • Database в CentOS (68)
        • Monitoring в CentOS (67)
        • Virtualization в CentOS/ Red Hat/ Fedora (42)
          • Docker (23)
          • Kubernetes (6)
          • KVM (5)
          • OpenVZ (2)
          • Vagrant (5)
          • VirtualBox (6)
          • VMWare (3)
          • ArgoCD (1)
          • Concourse (1)
          • Gitlab (1)
          • Jenkinks (4)
          • Spinnaker (1)
          • Apache (35)
          • Cherokee (1)
          • DNS (3)
          • FTP (10)
          • Nginx (33)
          • PHP (34)
          • Proxy для RedHat’s (2)
          • Tomcat (2)
          • Voice (2)
          • Панели управления в CentOS/Red Hat/Fedora (27)
          • Прокси сервер на CentOS/RHEL/Fedora (4)
          • Установка и настройка почты на CentOS/RHEL/Fedora (14)
          • Хранилища (clouds) (1)

          соц сети

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Архив новостей

          Свежие записи

          Свежие комментарии

          • Глеб к записи Установка Adobe Flash Player в Debian/Ubuntu/Mint
          • Максим к записи Заблокировать User Agents используя Nginx
          • Денис к записи Как включить EPEL репозиторий на CentOS
          • Гость к записи Закомментировать/Раскомментировать строки vi/vim в Unix/Linux
          • Sergey к записи Установка и настройка OpenVPN сервера на Debian/Ubuntu/Linux Mint

          Источник

          How can I find out my user name ( system login username in ubuntu 20.04 )? [closed]

          Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

          This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

          enter image description here

          How do i find my system login username in Ubuntu 20.04.3 LTS ?

          Just type in whoami at the command line. Or if you need it in a script variable, try something like user=$(whoami) (then echo $user or whatever).

          1 Answer 1

          Use this solution if you didn’t encrypt your home directory.

          Do you still have the installation media(LiveCD/USB) from which you installed Ubuntu? Boot from it and select Try Ubuntu.

          Go to Files and then, you will see you already installed Ubuntu partition. Click on it, it will mount.

          Go to /home. Here you will see a list of all users on the system that you have created.

          To jog your memory, however, what is your name? Did you enter the same name while installing Ubuntu? Do you recall the name that was displayed on the login prompt where you entered your password? Ubuntu by default sets the username as your first name in lowercase.

          Example; name= John Doe, automatically set username= john

          Источник

          How can I look up a username by id in linux?

          Is there a command to lookup up a username from a uid ? I realize this can be done by looking at the /etc/passwd file but I’m asking if there is an existing command to to this, especially if the user executing it is not root. I’m not looking for the current user’s username, i.e. I am not looking for whoami or logname . This also made me wonder if on shared web hosting this is a security feature, or am I just not understanding something correctly? For examination, the /etc/passwd file from a shared web host:

          root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin news:x:9:13:news:/etc/news: uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin nscd:x:28:28:NSCD Daemon:/:/sbin/nologin vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin pcap:x:77:77::/var/arpwatch:/sbin/nologin rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin avahi:x:70:70:Avahi daemon:/:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin haldaemon:x:68:68:HAL daemon:/:/sbin/nologin xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin avahi-autoipd:x:100:104:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin named:x:25:25:Named:/var/named:/sbin/nologin mailman:x:32006:32006::/usr/local/cpanel/3rdparty/mailman/mailman:/usr/local/cpanel/bin/noshell dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin mysql:x:101:105:MySQL server:/var/lib/mysql:/bin/bash cpaneleximfilter:x:32007:32009::/var/cpanel/userhomes/cpaneleximfilter:/usr/local/cpanel/bin/noshell nagios:x:102:106:nagios:/var/log/nagios:/bin/sh ntp:x:38:38::/etc/ntp:/sbin/nologin myuser:x:1747:1744::/home/myuser:/usr/local/cpanel/bin/jailshell 
          drwx------ 3 root root 1024 Apr 16 02:09 spamd-22217-init/ drwxr-xr-x 2 665 664 1024 Apr 4 00:05 update-cache-44068ab4/ drwxr-xr-x 4 665 664 1024 Apr 17 15:17 update-extraction-44068ab4/ -rw-rw-r-- 1 665 664 43801 Apr 17 15:17 variable.zip -rw-r--r-- 1 684 683 4396 Apr 17 07:01 wsdl-13fb96428c0685474db6b425a1d9baec 

          We can see root is the owner of some files, and root is also showing up in /etc/passwd , however the other users/groups all show up as numbers.

          Источник

Оцените статью
Adblock
detector