Welcome to the new Linux Foundation Forum!

Can't view cwd, environ, mem or status fields

Hi there,

I'm going through Lab 2.2 and can view the contents of cmdline inside a process (1177) in the /proc directory but Can't view cwd, environ, mem or status fields. I'm using the cat command, should I use another command or is not seeing the contents the point of the exercise?

Comments

  • coopcoop Posts: 341

    Depending which process you are looking at, you may need to use sudo, For a process I own:

    q8:/proc/5093>cat environ
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busHOME=/home/coopLANG=en_US.UTF-8LOGNAME=coopPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binSHELL=/bin/bashUSER=coopXDG_RUNTIME_DIR=/run/user/1000MANAGERPID=4973LISTEN_PID=5093LISTEN_FDS=1LISTEN_FDNAMES=dbus.socketINVOCATION_ID=8283f11aff2c45a5bf1d839248c4e5d8JOURNAL_STREAM=8:67518XDG_DATA_DIRS=/home/coop/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/q8:/proc/5093>

    q8:/proc/5093>ls -l cwd
    lrwxrwxrwx 1 coop coop 0 Feb 25 08:12 cwd -> /usr/local/coop8
    q8:/proc/5093>
    (cwd is always a symbolic link to a directory, so you cannot "cat" it.

    mem is never viewable, it is used for binary read and writes, don't mess with it.\

    q8:/proc/5093>cat status
    Name: dbus-daemon
    Umask: 0022
    State: S (sleeping)
    Tgid: 5093
    .....

    ( a long listing)

    I suspect you tried to look at a process that is not yours and so the s

  • coopcoop Posts: 341

    I got cut off. Check if the process is yours, I suspect it is not and you have to do sudo to look at it

  • Hi,

    As Coop said, it would be related to permissions, as in this case:

    [email protected]:/proc$ ls -F 18
    ls: cannot read symbolic link '18/cwd': Permission denied
    ls: cannot read symbolic link '18/root': Permission denied
    ls: cannot read symbolic link '18/exe': Permission denied
    arch_status coredump_filter io mountstats patch_state smaps timers
    attr/ cpuset limits net/ personality smaps_rollup timerslack_ns
    autogroup [email protected] loginuid ns/ projid_map stack uid_map
    auxv environ map_files/ numa_maps [email protected] stat wchan
    cgroup [email protected] maps oom_adj sched statm
    clear_refs fd/ mem oom_score schedstat status
    cmdline fdinfo/ mountinfo oom_score_adj sessionid syscall
    comm gid_map mounts pagemap setgroups task/

    As you see, I'm getting some "Permission denied" messages with a non-privileged user.

    Regards,
    Luis.

  • Thanks, Coop and Luis. I see why I couldn't view these field now.
    Much appreciated.
    Owen.

  • luisviveropenaluisviveropena Posts: 365

    It's a pleasure!

    Regards,
    Luis.

Sign In or Register to comment.